MyBB Community Forums

Full Version: Search in comma separated values in Database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello friends, if you want to search in the database for comma separated values, you can easily do this with FIND_IN_SET function.

Example : Suppose several values like the following are stored in the users additionalgroups field.
1) 1,3,5
2) 4,2,1

Now you want to find users who have a value of 1

You can use this function as follows.
$query = $db->simple_select("users","uid","FIND_IN_SET('1', `additionalgroups`)>0");