Escaping underscores in LIKE - Mailing list pgsql-general

From dev@archonet.com
Subject Escaping underscores in LIKE
Date
Msg-id 20010308.9204000@client.archonet.com
Whole thread Raw
Responses Re: Escaping underscores in LIKE
List pgsql-general
Am I doing something stupid trying to escape an underscore in LIKE?
Version 7.1b3


richardh=> select * from foo;
  a
-----
 a_c
 a_d
 abc
(3 rows)

richardh=> select * from foo where a like 'a_c';
  a
-----
 a_c
 abc
(2 rows)

richardh=> select * from foo where a like 'a\_c';
  a
-----
 a_c
 abc
(2 rows)

richardh=> select * from foo where a like 'a\_c' escape '\\';
  a
-----
 a_c
 abc
(2 rows)

richardh=> select * from foo where a like 'ax_c' escape 'x';
  a
-----
 a_c
(1 row)

- Richard Huxton



pgsql-general by date:

Previous
From: dev@archonet.com
Date:
Subject: CONTRIB: int8 sequence simulator
Next
From: "Trewern, Ben"
Date:
Subject: RE: Data types?