Re: [SQL] how to escape _ in select

2010-07-29 Thread Thomas Kellerer
Wes James, 28.07.2010 19:35: I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't working. ( http://www.postgresql.org/docs/8.3/static/functions-matching.html ) The text bet

Re: [SQL] how to escape _ in select

2010-07-28 Thread Dmitriy Igrishin
Hey James, Because in future releases the default value of the "standard_conforming_strings" parameter will change to "on" for improved standards compliance. You should use string constants with C-Style escapes. Please, see http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNT

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
On Wed, Jul 28, 2010 at 12:15 PM, Little, Douglas wrote: > Wes. > > You probably missed the part in bold.   You need to double the backslash. > > select 'ab5c' like '%\_c' > > t > Why doesn't this work? select * from table where field::text ilike '%\\\%' WARNING: nonstandard use of \\ in a str

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
Thanks Douglas and Tom - I missed that second \. -wes -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] how to escape _ in select

2010-07-28 Thread Tom Lane
Wes James writes: > I'm trying to do this: > select * from table where field::text ilike '%\_%'; > but it doesn't work. You need to double the backslash, because one level of backslash-escaping will be eaten by the string literal parser. In the above example, the actual string value seen by ILIK

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
On Wed, Jul 28, 2010 at 12:47 PM, Justin Graf wrote: > On 7/28/2010 12:35 PM, Wes James wrote: >> I'm trying to do this: >> >> select * from table where field::text ilike '%\_%'; >> >> but it doesn't work. >> >> How do you escape the _ and $ chars? >> >> The docs say to use \, but that isn't worki

Re: [SQL] how to escape _ in select

2010-07-28 Thread Justin Graf
On 7/28/2010 12:35 PM, Wes James wrote: > I'm trying to do this: > > select * from table where field::text ilike '%\_%'; > > but it doesn't work. > > How do you escape the _ and $ chars? > > The docs say to use \, but that isn't working. > > ( http://www.postgresql.org/docs/8.3/static/functions-mat

[SQL] how to escape _ in select

2010-07-28 Thread Wes James
I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't working. ( http://www.postgresql.org/docs/8.3/static/functions-matching.html ) The text between '%...%' can be longer, I'm