CONTAINS in row

Hi

Is there any option to check if a character exist in a row

for example i have table as below

id name numvals
1 a 1,2,3
2 b 2,3,4,5,15
3 c 13,14,1,3,5
4 d 20,2,200
5 e 50,2,200
6 f 15

 SELECT * from `table` WHERE `numvals`[B] NOT IN[/B] (5) 

Im looking for alternative for NOT IN so that rows returned will be

1 a 1,2,3
4 d 20,2,200
5 e 50,2,200
6 f 15

Thanks in advance

The solution is normalizing your table. Comma separated values in a table column indicate there’s something wrong in your database design, that’ll create you problems sooner or later (as you found out right now :slight_smile: ).

I have tried something like this, im getting the results but still testing :slight_smile:


SELECT *,FIND_IN_SET('5',numvals) as `existval` FROM `table`  WHERE FIND_IN_SET('5',numvals)=0

Doesn’t scale well. Normalize your data as suggested.

Thanks for your comment, i will try that way :slight_smile: