Re: selecting recs based on a tmp tbl vals that are wildcarded ?

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: selecting recs based on a tmp tbl vals that are wildcarded ?
Date: 2009-01-08 15:03:01
Message-ID: 15603.1231426981@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:
> 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurent ROCHE 2009-01-08 16:10:11 version number between pgdump and server
Previous Message Gauthier, Dave 2009-01-08 14:48:05 selecting recs based on a tmp tbl vals that are wildcarded ?