我table A, B and C
SQL - 相关子查询
我要回表A中不表B和该列表中存在的所有条目表不存在C.
select * from table_A as a
where not exists (select 1 from table_B as b
where a.id = b.id)
的多层
这让我在一个不在B.条目的第一个结果但现在我想只有那些还没有C.
我试过的口味的这个结果的条目:
select * from table_A as a
where not exists (select 1 from table_B as b
where a.id = b.id)
AND
where not exists (select 1 from table_C as c
where a.id = c.id)
但这不是正确的逻辑。如果有一种方法可以存储来自第一个查询的结果,然后从表C中不存在的结果中选择*,但我不确定该怎么做。我很感激帮助。
你使用什么数据库系统演示? –
我正在使用MS sql – codingknob