难题啊,求救高手。一条sql 求解!

guoheng90 2010-06-22 10:59:32

A表结果:
e f g
---------- ---------- ----------
1 1 1
2 2 2
3 3 3
4 4 4


B表结果:
e f g
---------- ---------- ----------
1 1 1


想要的结果是:A表存在B表不存在的数据,即结果为:
e f g
---------- ---------- ----------
2 2 2
3 3 3
4 4 4
...全文
74 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SQL77 2010-06-22
  • 打赏
  • 举报
回复
SELECT * FROM A WHERE CHECKSUM(*) NOT IN(SELECT CHECKSUM(*) FROM B)
albert_sky 2010-06-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 small_agile 的回复:]

SQL code


declare @tb table (e int,f int , g int)
insert @tb select
1,1,1 union all
select 2,2,2 union all
select 3,3,3 union all
select 4,4,4

declare @tc table (e int,f int , g int)
insert @tc s……
[/Quote]



select t.e,t.f,t.g from @tb t,@tc tc where
tc.e<>t.e and tc.f<>t.f and tc.g <> t.g
small_agile 2010-06-22
  • 打赏
  • 举报
回复


declare @tb table (e int,f int , g int)
insert @tb select
1,1,1 union all
select 2,2,2 union all
select 3,3,3 union all
select 4,4,4

declare @tc table (e int,f int , g int)
insert @tc select
1,1,1



select t.e,t.f,t.g from @tb t,(select * from @tc)tc where
tc.e<>t.e and tc.f<>t.f and tc.g <> t.g

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧