Re: Escaping underscores in LIKE

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Escaping underscores in LIKE
Date: 2001-03-09 08:55:04
Message-ID: 005901c0a876$a380abe0$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> dev(at)archonet(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message De Leeuw Guy 2001-03-09 11:37:37 Create trigger problem :
Previous Message Einar Karttunen 2001-03-09 07:31:04 Re: inheritance and primary/foreign keys