MySQL Select Where IN Comma Separated List
-
Good evening,
I have a very simple request but I can’t seem to get it 100% correct and your inputs would be greatly appreciated.First I have a Table with columns
ID, entity_id,assigned_users,group_name
1 | 1 | 1,2,3,4,5 | Group 1
2 | 1 | 1,2,3 | Group 2My SQL Query is:
$SQL_Query=("SELECT group_name FROM mytable WHERE assigned_users IN (".$user_id.")");
If the user ID is 1st in the string (example, user 1) then this works.
But if user_id = 2 (or anything after the first position) then it does not work.Can someone please assist me and help me where I am making this silly mistake?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘MySQL Select Where IN Comma Separated List’ is closed to new replies.