SQL Regular expression

Started by Albert Chenover 26 years ago2 messagesgeneral
Jump to latest
#1Albert Chen
chen6178@hotmail.com

Hi,

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*';

Appearently, it doesn't work. Would anyone know how to do, thanks in
advance.

-Albert

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

#2John M. Flinchbaugh
glynis@butterfly.hjsoft.com
In reply to: Albert Chen (#1)
Re: [GENERAL] SQL Regular expression

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@hjsoft.com <- john@cs.millersv.edu |
| glynis@netrax.net http://www.hjsoft.com/~glynis/ |
~~Powered by Linux: Reboots are for hardware upgrades only~~