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.
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.
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;
you can use FIND_IN_SET()
FIND_IN_SET('a','a,b,c,d,e');
http://www.w3resource.com/mysql/string-functions/mysql-find_in_set-function.php
You can use a like clause on the column, for eg, if the column name contains these values in the users table you can use this query
select * from users where name like "%b%";
Try this:
select * from users where name like "%,b,%" OR name like "b,%" OR name like "%,b" ;