This is a discussion on select a range of data within the pgsql Admins forums, part of the PostgreSQL category; --> If I have a column with a value like "abc2457", "efg1234", how do I select col from table where ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |
| |||
| 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/s...-matching.html regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| ||||
| 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/i...g.html#AEN9312 -Jon -- Senior Systems Developer Media Matters for America http://mediamatters.org/ ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |