27,579
社区成员
发帖
与我相关
我的任务
分享
--测试数据
if not object_id(N'Tempdb..#a') is null
drop table #a
Go
Create table #a([type] nvarchar(23),[name] nvarchar(22))
Insert #a
select N'Ali',N'D0' union all
select N'Ali',N'D1' union all
select N'Ali',N'D2' union all
select N'WX',N'D0'
GO
if not object_id(N'Tempdb..#b') is null
drop table #b
Go
Create table #b([type] nvarchar(23),[name] nvarchar(22))
Insert #b
select N'Ali',N'D0' union all
select N'Ali',N'D1' union all
select N'WX',N'D0'
Go
--测试数据结束
Select * from #a WHERE NOT EXISTS(SELECT 1 FROM #b WHERE #a.name=name AND #a.type=type)