pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Wes James <comptekki@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: how to escape _ in select
Date: Wed, 28 Jul 2010 14:34:20 -0400
Message-ID: <20369.1280342060@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTi=7K_xTEQSFaOX3=K_YDiNjvDedjcfBSTRpO240@mail.gmail.com>
References: <AANLkTi=7K_xTEQSFaOX3=K_YDiNjvDedjcfBSTRpO240@mail.gmail.com>

Wes James <comptekki@gmail.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



view thread (8+ messages)  latest in thread

Message-ID: <20369.1280342060@sss.pgh.pa.us>
Permalink:  ../20369.1280342060@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20369.1280342060@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, comptekki@gmail.com
  Subject: Re: how to escape _ in select
  In-Reply-To: <20369.1280342060@sss.pgh.pa.us>

* 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