[英]Many-to-many sql select query containing multiple values, all values are taken into account
You can use aggregation and having
:您可以使用聚合并
having
:
select tq.question_id
from tagsquestions tq join
tags t
on tq.tag_id = t.id
where t.name in ('JS', 'CSS')
group by tq.question_id
having count(*) = 2;
This assumes that the tags assigned to a single question are distinct.这假设分配给单个问题的标签是不同的。 That seems like a reasonable assumption.
这似乎是一个合理的假设。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.