Search Postgresql Archives

Re: Question on the use of bracket expressions in Postgres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Dec 15, 2005, at 0:29 , Jimmy Rowe wrote:

	select * from catalog where file_name like 'abc%def%.200[2-5]%';
The following select keeps returning "(0 rows)".

LIKE doesn't consider [2-5] to be a range, but rather the literal characters '[2-5]'. If you're looking for regex, take a look at the POSIX regex operator ~

http://www.postgresql.org/docs/current/interactive/functions- matching.html#FUNCTIONS-POSIX-REGEXP

See if something like file_name ~ 'abc.*def.*\.200[2-5]'

select '2003' ~ '200[2-5]' as "yup", '2006' ~ '200[2-5]' as "nope";
yup | nope
-----+------
t   | f
(1 row)


Michael Glaesemann
grzm myrealbox com





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux