Search in comma separated values in Database
#1
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
3)1
4)6,7

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");
...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)