Re: [GENERAL] SQL Regular expression

From: "John M(dot) Flinchbaugh" <glynis(at)butterfly(dot)hjsoft(dot)com>
To: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] SQL Regular expression
Date: 1999-07-15 03:54:08
Message-ID: Pine.LNX.4.10.9907142350520.7950-100000@butterfly.hjsoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 14 Jul 1999, Albert Chen wrote:
> I want to search my database table named ex, whose the attribute is
> subject,
> and list the results that matches the keyword 'electric'.
> I run the SQL command: SELECT subject FROM ex WHERE subject='*electric*';

use one of the following:

select subject from ex where subject~'.*electric.*';

or

select subject from ex where subject like '%electric%';

the first uses postgresql's regular expressions, which are much like unix
regex. the second uses the sql standard like clause. this one will be
more portable to other dbms.

____________________}John Flinchbaugh{______________________
| -> glynis(at)hjsoft(dot)com <- john(at)cs(dot)millersv(dot)edu |
| glynis(at)netrax(dot)net http://www.hjsoft.com/~glynis/ |
~~Powered by Linux: Reboots are for hardware upgrades only~~

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tiago Hermans 1999-07-15 06:03:04 Multi-Threading?
Previous Message Ole Gjerde 1999-07-15 03:25:44 (Even) More on Weird index problem