Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if value exists in a comma separated list [duplicate]

Tags:

sql

mysql

I have following values in my sql column:-

a,b,c,d e,f

I want to check if b is present in the column.

like image 989
Daljeet Singh Avatar asked Jul 28 '15 11:07

Daljeet Singh


1 Answers

You can use FIND_IN_SET():

FIND_IN_SET('b',yourcolumn) > 0

As an example to be used in a query:

SELECT * FROM yourtable WHERE FIND_IN_SET('b',yourcolumn) > 0;
like image 60
vhu Avatar answered Oct 08 '22 13:10

vhu