I want to select those ids where staff id contain 3. Below is my database structure:
ID NAME Staff_ids
-----------------------
1 A 0,212,5
2 B 2,3,600
3 C 0,1,4
I want a query where I can select those ids having 3 in staff_ids column. How can I do that please help
You can use FIND_IN_SET
.
Here is SQLFiddle Demo
SELECT * FROM table_name WHERE FIND_IN_SET('3',Staff_ids)>0
Hope this helps.
SELECT *
FROM ABC
WHERE Staff_id IN ('3');
Check if this helps