27,579
社区成员
发帖
与我相关
我的任务
分享
id
001
002
003
004
005
006
002
003
005
003
004
005
declare @t1 table (id int)
insert into @t1
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6
--> 测试数据: @t2
declare @t2 table (id int)
insert into @t2
select 1
--> 测试数据: @t3
declare @t3 table (id int)
insert into @t3
select 3
select * from @t1
except
(select * from @t2
union
select * from @t3)
SELECT * FROM A
WHERE NOT EXISTS
(
SELECT 1 FROM (
SELECT * FROM B
UNION
SELECT * FROM C) AS D WHERE A.id = D.id
)
--1
select * from a
where not exists(select 1 from b where b.id=a.id)
and not exists(select 1 from c where c.id=a.id)
select * from A
where not exists
(
select * from B where A.id = id
)
and
not exists
(
select * from C where A.id = id
)