mysql查询问题

需求:根据选择不同的分类id,查找到同时属于选中的分类的文章id

sql语句:

select result,GROUP_CONCAT(category_id) from (select category_id,(article_id)result from article_category WHERE category_id in (24,25,31) GROUP BY category_id,result)b GROUP BY result HAVING count(category_id)=3

注意:这里的count值就是所选的分类的个数

原文地址:https://www.cnblogs.com/LULULI/p/10813282.html