In mysql, when a field of a table is a string type, the content is multiple elements separated by commas like "a,b,c,d".
For example, the table Test
id | name | scope |
1 | Zhang San | a,b,c,d |
2 | Li Si | a, b, cd |
How to realize the data containing the element b in the query scope? If you use like %b%, even the "Li Si" will be found.
This can be achieved with the find_in_set function of mysql
The sql is like this: select * from Test where find_in_set('b',scope);