Example: {code ...} take out the user_id with 2 IDs. the result 1, 2 (containing separate 2) like method obviously does not work. The simple and beautiful SQL statement shows that the field structure is greatly changed downstairs, this is not allowed currently. Because the entire project is successful, if I am using this one:
id user_id 1 2,32,42 3,63,23 4,62,7
Retrieveuser_idIn2Ofid, Result = "1, 2 (contains separate 2)
The like method obviously does not work.
Simple and beautiful SQL statements
We can see that there isLargeIt is not allowed to change the field structure. This is because the entire project is accessible. if I change the field structure when I call it elsewhere, unpredictable problems may occur.
Reply content:
Example:
id user_id 1 2,32,42 3,63,23 4,62,7
Retrieveuser_idIn2Ofid, Result = "1, 2 (contains separate 2)
The like method obviously does not work.
Simple and beautiful SQL statements
We can see that there isLargeIt is not allowed to change the field structure. This is because the entire project is accessible. if I change the field structure when I call it elsewhere, unpredictable problems may occur.
SELECT id FROM table WHERE find_in_set('2',user_id);
Id user_id
1, 2, 32, 4,
2, 3, 63, 2,
3, 4, 62, 7,
If this is the case, you can do like.
In fact, it is better to split the intermediate table.
Table product
id 1 2 3
Table user
user_id 234632 6263
Intermediate table
product_id user_id1 21 321 42 22 632 33 43 623 7
We recommend that you change the table structure! This is really hard to get. Or change the data storage method as shown in figure
id user_id 1 [2],[32],[4]2 [3],[63],[2]3 [4],[62],[7]
In this way, you can use fuzzy search. However, it is recommended that you modify table data.
Json type obtained by mysql5.7