Mysql Is there any way to query? For example, the string '3,5' is within the string '3,4,5,2'
The situation is probably like this
How many users are there? An attribute, the attribute ID is stored in a field in the user table
For example, user_attr, the value storage format is: '3,4,5,2',
Explanation: For example, numbers are attributes ID
Now the front end needs to query �%9
find_in_set() Learn more
like correct answer
There is no need to use sql query here. Convert 3,5 passed from the front end into array [3,5], and then 3,4,5,2 are also converted into arrays. Compare them to know whether they are in it.
Convert 3 and 5 into arrays, loop and splice where conditions, user_attr like '%3%' or user_attr like '%5%' groug by user id? Maybe the efficiency is not that high, it can be achieved