Re: Help please - completely baffled by quoting

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Tim Robinson" <tim(dot)robinson(at)blueyonder(dot)co(dot)uk>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help please - completely baffled by quoting
Date: 2004-06-20 13:06:38
Message-ID: 200406201506.38447.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Robinson wrote:
> select * from temp where a like 'a\\\'%'
>
> this should return all strings starting with a\' but it returns
> nothing!!!

\ is also the quoting character of LIKE, in addition to being a quoting
character on the string literal level. If you want all strings
starting with a\' then use something like:

a LIKE 'a\\\'%' ESCAPE '!'

where '!' selects some other escape character for LIKE that doesn't get
in the way. The documentation on LIKE contains the details on this
mechanism.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-06-20 13:11:27 Re: pg_proc_proname_args_nsp_index error
Previous Message Tim Robinson 2004-06-20 12:40:54 Help please - completely baffled by quoting