pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedselect a range of data
3+ messages / 3 participants
[nested] [flat]
* select a range of data
@ 2007-07-20 19:00 Jessica Richard <rjessil@yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Jessica Richard @ 2007-07-20 19:00 UTC (permalink / raw)
To: pgsql-admin
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: select a range of data
@ 2007-07-20 19:19 Jon Sime <jsime@mediamatters.org>
parent: Jessica Richard <rjessil@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jon Sime @ 2007-07-20 19:19 UTC (permalink / raw)
To: pgsql-admin
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/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: select a range of data
@ 2007-07-20 19:19 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jessica Richard <rjessil@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2007-07-20 19:19 UTC (permalink / raw)
To: Jessica Richard <rjessil@yahoo.com>; +Cc: pgsql-admin
Jessica Richard <rjessil@yahoo.com> 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-07-20 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-07-20 19:00 select a range of data Jessica Richard <rjessil@yahoo.com>
2007-07-20 19:19 ` Jon Sime <jsime@mediamatters.org>
2007-07-20 19:19 ` Tom Lane <tgl@sss.pgh.pa.us>
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