First look at the syntax of the Find_in_set function in the MySQL manual:
| The code is as follows |
Copy Code |
Find_in_set (Str,strlist) |
If string str is in the strlist of a string list of n chains, the return value ranges from 1 to N. A list of strings is a string of strings that are separated by a number of ', ' symbols. If the first argument is a constant string, and the second is the Type SET column, the Find_in_set () function is optimized, using bit computations. If STR is not strlist or strlist is an empty string, the return value is 0. If any of the arguments are null, the return value is null. This function will not work correctly when the first argument contains a comma (', ').
mysql> SELECT find_in_set (' B ', ' a,b,c,d ');
-> 2
Querying in the database
Save all of the user's permission IDs in this field. For example, there are five privileges such as 1,2,3,4,5
Find out which users have permissions with a permission ID of 1
| code is as follows |
copy code |
| select * from User where Find_in_set (' 1 ', purview); |