From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: how to escape _ in select
Date: Thu, 29 Jul 2010 09:16:44 +0200
Message-ID: <i2r9ss$gt0$1@dough.gmane.org> (raw)
In-Reply-To: <AANLkTi=7K_xTEQSFaOX3=K_YDiNjvDedjcfBSTRpO240@mail.gmail.com>
References: <AANLkTi=7K_xTEQSFaOX3=K_YDiNjvDedjcfBSTRpO240@mail.gmail.com>
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 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 \\
>
To get around the somewhat quirky usage of backslashes, you can simply define a different esacpe character:
select *
from table
where field::text ilike '%@_%' escape '@';
Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: how to escape _ in select
In-Reply-To: <i2r9ss$gt0$1@dough.gmane.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox