The mysql query condition is a function to be in a field

        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);

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326856492&siteId=291194637