Received: from mailgw02.execpc.com (mailgw02.execpc.com [169.207.3.78]) by hub.org (8.8.8/8.7.5) with ESMTP id RAA22581 for ; Mon, 29 Jun 1998 17:39:39 -0400 (EDT) Received: from earth.execpc.com (trowbrid@earth.execpc.com [169.207.16.1]) by mailgw02.execpc.com (8.9.0) id QAA29700 for ; Mon, 29 Jun 1998 16:39:38 -0500 (CDT) Received: (from trowbrid@localhost) by earth.execpc.com (8.8.8) id QAA20652 for pgsql-sql@postgreSQL.org; Mon, 29 Jun 1998 16:39:38 -0500 (CDT) Message-Id: <199806292139.QAA20652@earth.execpc.com> Subject: Re: [SQL] Finding strings inside a field... To: pgsql-sql@postgreSQL.org Date: Mon, 29 Jun 1998 16:39:37 -0500 (CDT) From: "Tim J Trowbridge" In-Reply-To: from "Dan Delaney" at Jun 29, 98 05:28:02 pm reply-to: trowbrid@writeme.com from: trowbrid@writeme.com X-Mailer: ELM [version 2.4 PL25-execpc] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Dan Delaney wrote: > > Hello all. > Could any one tell me if the following is possible using > PostgreSQL? > > 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'; Try this: SELECT FROM testtable WHERE description like '%foobar%'; Note that this isn't case insensitive. -- Tim J Trowbridge trowbrid@writeme.com Interested in my genealogy? http://www.execpc.com/~trowbrid