Introduction to the use of find_in_set in Mysql

  • 2020-05-15 02:22:11
  • OfStack

Examples:

A field (purview) in the user table (user) represents the permissions of that user

Store all the user's permissions, id, in this field. For example, there are five permissions: 1,2,3,4,5

Find which users have permissions of id 1


select * from user where find_in_set('1',purview); 

sql statement

sql explains: find out all the information of all users who have the 1 privilege.

The goal of this data table design is to reduce the number of tables, but to make it more difficult to update!


Related articles: