how to escape _ in select

From: Wes James <comptekki(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: how to escape _ in select
Date: 2010-07-28 17:35:18
Message-ID: AANLkTi=7K_xTEQSFaOX3=K_YDiNjvDedjcfBSTRpO240@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 just trying to figure out
how to escape some things. I've found that ' works with '' and \
works with \\

thx,

-wes

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Wes James 2010-07-28 18:07:34 Re: how to escape _ in select
Previous Message Torsten Zühlsdorff 2010-07-28 06:45:02 Re: [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them