From: Brett W. McCoy <bmccoy@lan2wan.com>
To: Dan Delaney <dionysos@dionysia.org>
Cc: PostgreSQL SQL Discussion <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Finding strings inside a field...
Date: Mon, 29 Jun 1998 17:36:20 -0400 (EDT)
Message-ID: <Pine.LNX.3.96.980629172202.460D-100000@dragosani.lan2wan.com> (raw)
In-Reply-To: <Pine.BSF.3.96.980629172405.6263I-100000@dionysia.org>
On Mon, 29 Jun 1998, Dan Delaney wrote:
> I want to be able do a SELECT and search for a string INSIDE OF a
> field. So, say I want to get all record in testtable which contain
> the word "foobar" inside the "description" attribute. The following
> will only get those records in which the "description" attribute
> contains ONLY the word "foobar":
>
> SELECT FROM testtable WHERE description='foobar';
>
> What do I need to do to get all the record that have "foobar"
> ANYWHERE within the "description" field?
You'll want to use the LIKE operator, with '%' and '_' used as wildcard
operators similar to '*' and '?' used in the Unix CLI.
SELECT * from MyDB WHERE DESCRIPTION LIKE "%foobar%";
Brett W. McCoy
http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
"The number of UNIX installations has grown to 10, with more expected."
-- The UNIX Programmer's Manual, 2nd Edition, June, 1972
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: bmccoy@lan2wan.com, dionysos@dionysia.org
Subject: Re: [SQL] Finding strings inside a field...
In-Reply-To: <Pine.LNX.3.96.980629172202.460D-100000@dragosani.lan2wan.com>
References: <Pine.BSF.3.96.980629172405.6263I-100000@dionysia.org> <Pine.LNX.3.96.980629172202.460D-100000@dragosani.lan2wan.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox