Re: Syntax for wildcard selection

From: Jason Turner <jasont(at)indigoindustrial(dot)co(dot)nz>
To: Scott Holmes <sholmes(at)pacificnet(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Syntax for wildcard selection
Date: 2001-08-15 23:36:14
Message-ID: 20010816113614.A6590@camille.indigoindustrial.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)indigoindustrial(dot)co(dot)nz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2001-08-15 23:45:31 Re: Syntax for wildcard selection
Previous Message Scott Holmes 2001-08-15 23:06:16 Syntax for wildcard selection