For MySQL Query, The tid field stores the tag id of the article, which is a string separated by commas (,). now I want to use tags to find all the articles, such as "2 ", to find out that there are 2 articles IN all the tid fields. now I use the SELECT * FROM 't_ms_article 'Where 'tid' IN (2) statement to find only articles starting with 2, but it cannot be identified as '1, 2, 3 '.
Hope you can help me. I'm a Cainiao.
Reply to discussion (solution)
SELECT * FROM `t_ms_article` WHERE `tid` LIKE ‘%2%’;
SELECT * FROM `t_ms_article` WHERE `tid` LIKE ‘%2%’;
No. in this case, tags like 12 and 20 will also be found.
SELECT * FROM `t_ms_article` WHERE find_in_set('2', `tid`)
SELECT * FROM `t_ms_article` WHERE CONCAT(',',`tid`,',') LIKE ‘%,2,%’;
SELECT * FROM `t_ms_article` WHERE find_in_set('2', `tid`)
Thank you. I will solve it in a moment. please accept my knees!