07-20-2023, 05:51 AM
I have a field `COLORS (varchar(50))` in a my table `SHIRTS` that contains a comma delimited string such as `1,2,5,12,15,`. Each number representing the available colors.
When running the query `select * from shirts where colors like '%1%'` to get all the red shirts (color=1), I also get the shirts whose color is grey (=12) and orange (=15).
How should I rewrite the query so that is selects ONLY the color 1 and not all colors containing the number 1?
When running the query `select * from shirts where colors like '%1%'` to get all the red shirts (color=1), I also get the shirts whose color is grey (=12) and orange (=15).
How should I rewrite the query so that is selects ONLY the color 1 and not all colors containing the number 1?