[thelist] SQL (or ASP?) selecting from a multi-valued column

rudy r937 at interlog.com
Tue Feb 6 07:23:37 CST 2001


> SELECT *
> FROM display
> WHERE cat LIKE '%,#cat#,%' OR
> LEFT(cat,#strLen#) = '#cat#,' OR
> RIGHT(cat,#strLen#) = ',#cat#'


hi erik

that's actually really good, given the original question

watch out for databases which use a different wildcard character, and be
prepared to do some funky substringing for databases which do not have
LEFTor RIGHT functions

also, realize that LIKE means the index, if any, on the column may not be
used

finally, in elfur's case the mulitvalued column contained a comma-separated
list of foreign keys -- so joining this table to its parent would require
join conditions much like the above

ughghg

there are times when it's best just to bite the bullet and redesign...


rudy





More information about the thelist mailing list