你那个查询的条件明显就不对// tags表 `tags`.`title` = '聪明' AND `tags`.`title` = '勤奋' 这种数据根本就不存在SELECT * FROM userWHERE id IN ( SELECT uid FROM tags WHERE title IN ('聪明', '勤奋') GROUP BY uid HAVING count(uid) = 2);
select user.*,count(tags.uid)as num from user left join tags on `user`.id = tags.uid where (`tags`.`title` = '聪明' OR `tags`.`title` = '勤奋') group by tags.uid having count(tags.uid) > 1