REGEXP Conversion

From: Dave <david.c.watson_at_gmail.com>
Date: Wed, 10 Feb 2010 09:21:48 -0800 (PST)
Message-ID: <0d2b8262-7115-45d4-8161-49abe7294515_at_a5g2000yqi.googlegroups.com>



Hi,

Is anyone good at converting the following sql statement's LIKE clauses into 1 coherent REGEXP_LIKE? I came up with a couple of solutions but am interested in seeing if anyone has a more efficient way then what I produced.

Thanks,
Dave

SELECT *
  FROM demo_table
 WHERE TRIM (code) = TRIM ('918')

    OR TRIM (REGEXP_REPLACE (code, ' *, *', ',')) LIKE '%,' || TRIM
('918')

    OR TRIM (REGEXP_REPLACE (code, ' *, *', ',')) LIKE TRIM ('918') || ',%'

    OR TRIM (REGEXP_REPLACE (code, ' *, *', ',')) LIKE '%,' || TRIM
('918') || ',%';

Code Column has data stored with 1 to many codes, seperated by commas...

i.e. 829,58,189,918 Received on Wed Feb 10 2010 - 11:21:48 CST

Original text of this message