X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66BD4D1B443 for ; Sun, 25 Jul 2004 11:39:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87571-02 for ; Sun, 25 Jul 2004 14:39:13 +0000 (GMT) Received: from simmts8-srv.bellnexxia.net (simmts8.bellnexxia.net [206.47.199.166]) by svr1.postgresql.org (Postfix) with ESMTP id 8C21CD1B3A4 for ; Sun, 25 Jul 2004 11:39:02 -0300 (ADT) Received: from localhost ([67.71.24.121]) by simmts8-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20040725143819.JNWG28685.simmts8-srv.bellnexxia.net@localhost>; Sun, 25 Jul 2004 10:38:19 -0400 Received: from sympatico.ca ([192.168.250.6]) by (8.11.6/8.11.6) with ESMTP id i6PEdAg19622; Sun, 25 Jul 2004 10:39:10 -0400 Message-ID: <4103C656.4070109@sympatico.ca> Date: Sun, 25 Jul 2004 10:40:22 -0400 From: Jean-Luc Lachance User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en, en-us, en-gb, fr, fr-ca MIME-Version: 1.0 To: Markus Bertheau Cc: Keith Gallant , pgsql-sql@postgresql.org Subject: Re: SELECT from a list References: <1090763779.9204.1.camel@teetnang> In-Reply-To: <1090763779.9204.1.camel@teetnang> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200407/216 X-Sequence-Number: 18468 Markus Bertheau wrote: > В Вск, 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', ....) Better yet: SELECT * FROM table WHERE phrase ~ '^[0-9]'; >