From rjessil@yahoo.com Fri Jul 20 19:00:47 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id AFDDB9FC0B3 for ; Fri, 20 Jul 2007 16:00:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 34323-03 for ; Fri, 20 Jul 2007 16:00:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from web56410.mail.re3.yahoo.com (web56410.mail.re3.yahoo.com [216.252.111.89]) by postgresql.org (Postfix) with SMTP id E9E2F9FA0CC for ; Fri, 20 Jul 2007 16:00:25 -0300 (ADT) Received: (qmail 46199 invoked by uid 60001); 20 Jul 2007 19:00:20 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=qGRWddHPRCtLXV+54rU7/8mlC17JDSqQOwoPhFj2YgdZhaozgJyCpeT/pPfcFdwdSxoiTNTnxcXzs5R6lvJmefHUgKDUvA8fgRmONZvsxP9zUtLnws3iyQAfKK4AdBqMQOdRp4TqWKKDnpha7QniPrQmoJ1Pdmji58V2e1zAgV4=; X-YMail-OSG: FhUiAj0VM1ljnFScv80_iViOgw4O2DJu6254F9led8xla_TGiKUHMT1gdl__lJKm4VrMZsCZumfgI0K5G_PP7Tz4WHDRMBM9Z395 Received: from [198.119.134.32] by web56410.mail.re3.yahoo.com via HTTP; Fri, 20 Jul 2007 12:00:18 PDT Date: Fri, 20 Jul 2007 12:00:18 -0700 (PDT) From: Jessica Richard Subject: select a range of data To: pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-124330305-1184958018=:11791" Content-Transfer-Encoding: 8bit Message-ID: <497741.11791.qm@web56410.mail.re3.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.225 tagged_above=0 required=5 tests=AWL=0.964, BAYES_20=-0.74, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200707/234 X-Sequence-Number: 26215 --0-124330305-1184958018=:11791 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit If I have a column with a value like "abc2457", "efg1234", how do I select col from table where col like 'a[a-z]c24[0-9]7"? How do I handle the range bracket in the query? Thanks. --------------------------------- Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. --0-124330305-1184958018=:11791 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit If I have a column with a value like "abc2457", "efg1234",

how do I select col from table where col like 'a[a-z]c24[0-9]7"?

How do I handle the range bracket in the query?

Thanks.


Boardwalk for $500? In 2007? Ha!
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. --0-124330305-1184958018=:11791-- From jsime@mediamatters.org Fri Jul 20 19:20:33 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C260B9FB471 for ; Fri, 20 Jul 2007 16:20:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 47777-03 for ; Fri, 20 Jul 2007 16:20:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.mediamatters.org (mail.mediamatters.org [63.240.197.71]) by postgresql.org (Postfix) with ESMTP id 0ED769FA0CC for ; Fri, 20 Jul 2007 16:20:29 -0300 (ADT) Received: from [10.1.0.133] (63-146-242-133.dia.static.qwest.net [63.146.242.133]) by mail.mediamatters.org (Postfix) with ESMTP id 28FAB96C1AE for ; Fri, 20 Jul 2007 15:20:03 -0400 (EDT) Message-ID: <46A10AB1.8040103@mediamatters.org> Date: Fri, 20 Jul 2007 15:19:13 -0400 From: Jon Sime Organization: Media Matters for America User-Agent: Thunderbird 2.0.0.4 (X11/20070615) MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: select a range of data References: <497741.11791.qm@web56410.mail.re3.yahoo.com> In-Reply-To: <497741.11791.qm@web56410.mail.re3.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/236 X-Sequence-Number: 26217 Jessica Richard wrote: > If I have a column with a value like "abc2457", "efg1234", > > how do I select col from table where col like 'a[a-z]c24[0-9]7"? > > How do I handle the range bracket in the query? You can use the regular expression operator(s), like so: select * from table where column ~ 'a[a-z]c24[0-9]7'; For the full details: http://www.postgresql.org/docs/8.2/interactive/functions-matching.html#AEN9312 -Jon -- Senior Systems Developer Media Matters for America http://mediamatters.org/ From tgl@sss.pgh.pa.us Fri Jul 20 19:19:59 2007 Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 393B39FC0F0 for ; Fri, 20 Jul 2007 16:19:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 29534-01 for ; Fri, 20 Jul 2007 16:19:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C82999FC0D5 for ; Fri, 20 Jul 2007 16:19:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l6KJJqlA012569; Fri, 20 Jul 2007 15:19:52 -0400 (EDT) To: Jessica Richard cc: pgsql-admin@postgresql.org Subject: Re: select a range of data In-reply-to: <497741.11791.qm@web56410.mail.re3.yahoo.com> References: <497741.11791.qm@web56410.mail.re3.yahoo.com> Comments: In-reply-to Jessica Richard message dated "Fri, 20 Jul 2007 12:00:18 -0700" Date: Fri, 20 Jul 2007 15:19:52 -0400 Message-ID: <12568.1184959192@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/235 X-Sequence-Number: 26216 Jessica Richard writes: > how do I select col from table where col like 'a[a-z]c24[0-9]7"? > How do I handle the range bracket in the query? Using LIKE, you don't. However there are two other types of pattern-matching operators that do understand character classes: http://www.postgresql.org/docs/8.2/static/functions-matching.html regards, tom lane