pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antonio Fiol Bonnín <fiol@w3ping.com>
To: joe@jwebmedia.com
Cc: pgsql-general@postgresql.org
Subject: Re: Query Help
Date: Tue, 18 Dec 2001 10:35:07 +0100
Message-ID: <3C1F0DCB.20805@w3ping.com> (raw)
References: <20011217162919.74067.qmail@web14707.mail.yahoo.com>
	<3C1E5695.98B1EC4F@jwebmedia.com>

For your very particular purpose, you may try to use

----------------
select * from table where substring(column, 0,1) between '0' and '9';
----------------

For a more general purpose, try the ~ operator.

\do will give you a list of available operators
You should maybe care about ~* operator also (case insensitive).

If you need to match one among many regular expressions, you can try to 
store them in a little table, and then try:

----------------
select distinct table.* from table, regex_table where table.column ~ 
regex_table.regex;
----------------

DISTINCT is there to avoid that entries matching multiple regexps appear 
multiple times.

No guarantees on performance.

HTH,

Antonio


Joe Koenig wrote:

>Thanks for the responses - I was able to patch something together from
>the responses. On to the next thing - I want to do a search based on a
>reg ex. Does PostgreSQL have something like MySQL's "RLIKE"? I want to
>pull all records in a category that start with a number 0-9. The best
>way I saw was to do a UNION with all the numbers, but I figured there
>was a better way. Thanks,
>
>Joe
>





view thread (70+ messages)  latest in thread

Message-ID: <3C1F0DCB.20805@w3ping.com>
Permalink:  ../3C1F0DCB.20805@w3ping.com/
Also on:    postgresql.org/message-id/3C1F0DCB.20805@w3ping.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: fiol@w3ping.com, joe@jwebmedia.com
  Subject: Re: Query Help
  In-Reply-To: <3C1F0DCB.20805@w3ping.com>
  References: <20011217162919.74067.qmail@web14707.mail.yahoo.com> <3C1E5695.98B1EC4F@jwebmedia.com> <3C1F0DCB.20805@w3ping.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox