Re: Escape wildcard problems. - Mailing list pgsql-general

From Sam Mason
Subject Re: Escape wildcard problems.
Date
Msg-id 20081024155010.GK2459@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Escape wildcard problems.  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List pgsql-general
On Fri, Oct 24, 2008 at 08:12:38AM -0700, Gauthier, Dave wrote:
> select name from templates where name like '%\_cont\_%';
>
>           name
> ----------------------------------
> cgidvcontrol
> x8idvcontrol
> etc....
>
> I would expect to NOT see these because the "cont" is not preceded by
> and followed by an underscore (because I escaped them with \).

You need to escape the escape! backslash is the escape character in
literals as well as like patterns, so you need to double it up.  I think
you want to be doing:

  name LIKE '%\\_cont\\_%'



  Sam

pgsql-general by date:

Previous
From: Harald Fuchs
Date:
Subject: Re: Query m:n-Combination
Next
From: Alan Hodgson
Date:
Subject: Re: Escape wildcard problems.