There is an article table, and there is a field associated with tags in the article table tag
tag
The content of the field is basically like this: 1,2,3,333,230 ( Associated tag IDs, separated by commas)
Now there is a problem. I now want to find the article with tag ID 3. Using LIKE %3% seems to find out the contents of 333,230 tags
No change In the case of table structure, is there any query method?
SELECT * FROM test WHERE find_in_set('3',tag)
LIKE %,3,% just add a comma
find_in_set, use this to meet your requirements, don’t use like....
I recommend using another table to maintain the classification relationship. find_in_set is a full table scan without using indexes. There will be problems with the database by then