引用 3 楼 ACMAIN_CHM 的回复:select from 关系表 t where b=x and exists (select 1 from 关系表 where a=t.a and b=y) and exists (select 1 from 关系表 where a=t.a and b=z) 这个效率比起#2会更高吗?(假设会有很多Item,不止……
select from 关系表 t where b=x and exists (select 1 from 关系表 where a=t.a and b=y) and exists (select 1 from 关系表 where a=t.a and b=z)
SQL code?12345select afrom tbwhere b in ('x','y','z')group by a having count(distinct b)=3
select a from tb where b in ('x','y','z') group by a having count(distinct b)=3
56,679
社区成员
56,709
社区内容
加载中
试试用AI创作助手写篇文章吧