I have a table with a column containing a list (yes I know this violates normalization). I’m trying to find some sore of “overlap” function i.e.
SELECT * FROM TABLE WHERE 'a,b,c' OVERLAP TABLE.LISTCOLUMN
So, LISTCOLUMNcontains any or all of a, b, or c
Two options:
Use
regexp_like, if you’re using Oracle 10g or above:This matches everything from your table where
aorborcis in the column.Alternatively you can do the more horrible and difficult to maintain:
Here’s a little SQL Fiddle to demonstrate.
However, as you already know, normalising your database properly will save you a lot of pain in the longer run.