我是一个完整的 sql noob,所以我为接下来的 sql 屠杀道歉......
这是我要执行的操作的伪代码:
count(
join(
select( * from table X where a='stuff' and b='junk' ) as X1
select( * from table X where a='arg' and b='blarg' ) as X2
select( * from table X where a='narf' and b='foo' ) as X3
) where X1.c = X2.c = X3.c
)
是否可以在一次查询中获得此结果?
最佳答案
select count(*) from
(select * from table X where a='stuff' and b='junk') x1
join
(select * from table X where a='arg' and b='blarg' ) x2
on x1.c=x2.c
join
( select * from table X where a='narf' and b='foo' ) X3
on x2.c=x3.c
关于sql - 在同一个表上加入多个过滤的选择查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12714682/