Re: selecting recs based on a tmp tbl vals that are wildcarded ? - Mailing list pgsql-general

From Tom Lane
Subject Re: selecting recs based on a tmp tbl vals that are wildcarded ?
Date
Msg-id 15603.1231426981@sss.pgh.pa.us
Whole thread Raw
In response to selecting recs based on a tmp tbl vals that are wildcarded ?  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List pgsql-general
"Gauthier, Dave" <dave.gauthier@intel.com> writes:
> select * from footable where name in (select val from match_these)

> ... won't work because "in" implies equality.  I want something like...

> select * from footable where name like (select val from match_these)

What you need is

 select * from footable where name ~~ any (select val from match_these)

It would probably be clearer to write

 select * from footable where name like any (select val from match_these)

but the ANY syntax requires an operator name, so you have to write the
operator equivalent for LIKE.

            regards, tom lane

pgsql-general by date:

Previous
From: "Josh Harrison"
Date:
Subject: Re: Question about COPY command
Next
From: Sherman Brown
Date:
Subject: SQL state: 22P02 Error during a COPY FROM a CSV file