sql server - sql - multiple layers of correlated subqueries -
i have table a, b , c
i want return entries in table not exist in table b , of list not exist in table c.
select * table_a not exists (select 1 table_b b a.id = b.id)
this gives me first result of entries in not in b. want entries of result not in c.
i tried flavours of:
select * table_a not exists (select 1 table_b b a.id = b.id) , not exists (select 1 table_c c a.id = c.id)
but isnt correct logic. if there way store results first query , select * result not existent in table c. i'm not sure how that. appreciate help.
you have 2 where
clauses in (the external part of) second query. not valid sql. if remove it, should work expected:
select * table_a not exists (select 1 table_b b a.id = b.id) , not exists (select 1 table_c c -- removed a.id = c.id) ;
tested in sql-fiddle (thnx @alexander)
Comments
Post a Comment