Re: "like any" in reverse?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: "like any" in reverse?
Date: 2010-02-12 05:08:35
Message-ID: 18453.1265951315@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> writes:
> I want to find all records where any element of lst like 'j%'.
> This does not work...
> select * from foo where 'j%' like any(lst);

> Intuitively, you'd think....
> select * from foo where any(lst) like 'j%';
> ... but that's a syntax error.

Yeah, the ANY has to be on the right-hand side of the operator.
What you can do for this is build yourself a "reverse like"
operator, ie flip the left and right arguments within the function.
I'm pretty sure there are worked-out examples in the archives
if that's not enough of a hint for you.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2010-02-12 08:09:33 Re: Postgres standard versus Postgres Plus Advanced Server
Previous Message u235sentinel 2010-02-12 04:23:08 Re: Postgres Triggers issue