SELECT from a list

From: Keith Gallant <keith(at)justhosting(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: SELECT from a list
Date: 2004-07-25 13:18:17
Message-ID: PDENIKIKNMLHOJKGJDLGCEPCCGAA.keith@justhosting.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

I am wondering if it is possible to use a SINGLE LIKE statement for a
selection from a list.

For example: If I want to return all results that a phrase starts with a
number, can I make a call similar to the following:

SELECT * FROM table WHERE phrase LIKE
{'0%','1%','2%','3%','4%','5%','6%','7%','8%','9%'};

If not is there an easier way than having to call this:

SELECT * FROM table WHERE phrase LIKE '0%' OR phrase LIKE '1%' OR phrase
LIKE '2%' OR phrase LIKE '3%' OR phrase LIKE '4%' OR phrase LIKE '5%' OR
phrase LIKE '6%' OR phrase LIKE '7%' OR phrase LIKE '8%' OR phrase LIKE
'9%';

Thank you.

Keith

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau 2004-07-25 13:56:20 Re: SELECT from a list
Previous Message Tom Lane 2004-07-24 16:13:19 Re: Trigger functions with dynamic SQL