Thread: SQL Regular expression
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
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~~