Re: Syntax for wildcard selection - Mailing list pgsql-general

From Jason Turner
Subject Re: Syntax for wildcard selection
Date
Msg-id 20010816113614.A6590@camille.indigoindustrial.co.nz
Whole thread Raw
In response to Syntax for wildcard selection  (Scott Holmes <sholmes@pacificnet.net>)
Responses Re: Syntax for wildcard selection
List pgsql-general
[snip:Informix trouble]
> tried to do a wildcard search, thus "where field_name LIKE 'AB%VN'".  The
> trailing values (after the %) are not recognized correctly.
[...]
> How is this accomplished with PostgreSQL?  Are we limited to wildcard
> searches as "where field_name LIKE 'AB%'"?

Well, it's hardly a conclusive proof, but it works the way you'd hope
on a toy problem....


foo=> DROP TABLE test;
DROP
foo=> CREATE TABLE test (name varchar(20),age int);
CREATE
foo=> INSERT INTO test VALUES ('AGNES', 20);
INSERT 586226 1
foo=> INSERT INTO test VALUES ('HELMUT', 33);
INSERT 586227 1
foo=> INSERT INTO test VALUES ('ANDREW', 33);
INSERT 586228 1
foo=> INSERT INTO test VALUES ('AGNEW', 302);
INSERT 586229 1
foo=> SELECT * FROM test WHERE name LIKE 'AG%ES';

 name  | age
-------+-----
 AGNES |  20
(1 row)

foo=> SELECT * FROM test WHERE name LIKE 'AG%E';
 name | age
------+-----
(0 rows)

foo=> SELECT * FROM test WHERE name LIKE 'AG%EW';

 name  | age
-------+-----
 AGNEW | 302
(1 row)

Someone see anything I'm missing?

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
jasont@indigoindustrial.co.nz

pgsql-general by date:

Previous
From: Scott Holmes
Date:
Subject: Syntax for wildcard selection
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Syntax for wildcard selection