Re: Escape wildcard problems.

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Escape wildcard problems.
Date: 2008-10-24 15:50:10
Message-ID: 20081024155010.GK2459@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alan Hodgson 2008-10-24 15:58:25 Re: Escape wildcard problems.
Previous Message Harald Fuchs 2008-10-24 15:35:06 Re: Query m:n-Combination