Re: Escaping underscores in LIKE - Mailing list pgsql-general

From Richard Huxton
Subject Re: Escaping underscores in LIKE
Date
Msg-id 005901c0a876$a380abe0$1001a8c0@archonet.com
Whole thread Raw
In response to Escaping underscores in LIKE  (dev@archonet.com)
Responses Re: Escaping underscores in LIKE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
From: "Tom Lane" <tgl@sss.pgh.pa.us>

> dev@archonet.com writes:
> > Am I doing something stupid trying to escape an underscore in LIKE?

Ah so Yes.

> You need more backslashes.  Don't forget the string-literal parser eats
> one level of backslashes, before LIKE ever gets to see the pattern.
>
> regards, tom lane

Thanks Tom, as a 2-stage process it all makes sense. Tried it out in PHP too
and I end up with four backslashes (3 stages).

Another DOH! item for my notes.

- Richard Huxton


pgsql-general by date:

Previous
From: "Eric G. Miller"
Date:
Subject: Re: inheritance and primary/foreign keys
Next
From: Tom Lane
Date:
Subject: Re: Escaping underscores in LIKE