Re: SELECT from a list - Mailing list pgsql-sql

From Markus Bertheau
Subject Re: SELECT from a list
Date
Msg-id 1090763779.9204.1.camel@teetnang
Whole thread Raw
In response to SELECT from a list  (Keith Gallant <keith@justhosting.ca>)
Responses Re: SELECT from a list
List pgsql-sql
В Вск, 25.07.2004, в 15:18, Keith Gallant пишет:
> 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%';

WHERE SUBSTRING(phrase FROM 1 FOR 1) IN ('0', '1', ....)

--
Markus Bertheau <twanger@bluetwanger.de>



pgsql-sql by date:

Previous
From: Keith Gallant
Date:
Subject: SELECT from a list
Next
From: Jean-Luc Lachance
Date:
Subject: Re: SELECT from a list