Skip site navigation (1) Skip section navigation (2)

Re: Like problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: "Campbell, Lance" <lance(at)uiuc(dot)edu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Like problem
Date: 2008-02-13 16:52:41
Message-ID: 16828.1202921561@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Richard Huxton <dev(at)archonet(dot)com> writes:
> Campbell, Lance wrote:
>> WARNING:  nonstandard use of escape in a string literal
>> LINE 1: ...ct c1 from t1 where c1 like '%abc\_%';

> Either indicate you are using an escaped string: LIKE E'%abc\_%'

Actually that's wrong, what he'd need is LIKE E'%abc\\_%'
(or omit the E and ignore the warning).

Alternatively, set standard_conforming_strings to TRUE and write
LIKE '%abc\_%' ... but beware that that might break other parts
of your app that are expecting backslash to be special.

> Or, change the escape character: LIKE '%abcQ_%' ESCAPE 'Q'

Yeah, this might be the easiest localized solution.

			regards, tom lane

In response to

Responses

pgsql-sql by date

Next:From: Campbell, LanceDate: 2008-02-13 16:59:14
Subject: Re: Like problem
Previous:From: Richard HuxtonDate: 2008-02-13 16:42:20
Subject: Re: Like problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group