sql - MySQL query finding values in a comma separated string -
i have field colors (varchar(50)) in table shirts contains comma delimited string such 1,2,5,12,15,. each number representing available colors.
when running query select * shirts colors '%1%' red shirts (color=1), shirts who's color grey (=12) , orange (=15).
how should rewrite query selects color 1 , not colors containing number 1?
the classic way add comma's left , right:
select * shirts ',' + colors + ',' '%,1,%' but find_in_set works:
select * shirts find_in_set('1',colors) <> 0
Comments
Post a Comment