Re: how to escape _ in select

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wes James <comptekki(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how to escape _ in select
Date: 2010-07-28 18:34:20
Message-ID: 20369.1280342060@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Wes James <comptekki(at)gmail(dot)com> 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 ILIKE
is just %_%, so of course it doesn't do what you want.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Justin Graf 2010-07-28 18:47:26 Re: how to escape _ in select
Previous Message Wes James 2010-07-28 18:07:34 Re: how to escape _ in select