Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 685

Search in comma separated values in Database

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

Viewing all articles
Browse latest Browse all 685

Trending Articles