# 这个查询怎么实现，在线等待!!!!!!!!!!!!!!!!!!!!!!

huangjianfen 2009-04-01 09:37:39

select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

select A.* from T1 ,T2 where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B)

select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

...全文
92 16 打赏 收藏 转发到动态 举报

16 条回复

• 打赏
• 举报

[Quote=引用 15 楼 huangjianfen 的回复:]

select * from T1
where not exists (select T1.* from T1 a ,T2 b
where rtrim(a.A)=rtrim(b.A) AND rtrim(a.B)=rtrim(b.B) )
[/Quote]

huangjianfen 2009-04-01
• 打赏
• 举报

[Quote=引用 14 楼 mugua604 的回复:]
SQL code
select * from T1 a
where not exists (select * from T2
where rtrim(A)=rtrim(a.A) OR rtrim(B)=rtrim(a.B) )
[/Quote]

select * from T1 a
where not exists (select * from T2
where rtrim(A)=rtrim(a.A) AND rtrim(B)=rtrim(a.B) )

OK了

select * from T1
where not exists (select T1.* from T1 a ,T2 b
where rtrim(a.A)=rtrim(b.A) AND rtrim(a.B)=rtrim(b.B) )

mugua604 2009-04-01
• 打赏
• 举报

``````
select * from T1  a
where  not exists  (select * from T2
where rtrim(A)=rtrim(a.A) OR rtrim(B)=rtrim(a.B) )

``````
huangjianfen 2009-04-01
• 打赏
• 举报

[Quote=引用 12 楼 mugua604 的回复:]
SQL code
select * from T1 a
where not exists (select * from T2
where rtrim(A)=rtrim(a.A))
[/Quote]

mugua604 2009-04-01
• 打赏
• 举报

``````
select * from T1  a
where  not exists  (select * from T2
where rtrim(A)=rtrim(a.A))

``````
huangjianfen 2009-04-01
• 打赏
• 举报

[Quote=引用 2 楼 hyrongg 的回复:]
SQL code
select * from jam_T1
where not exists (
select 1 FROM T2
where rtrim(T2.A)=rtrim(T1.A) and rtrim(T2.B)=rtrim(T1.B)
)
[/Quote]

huangjianfen 2009-04-01
• 打赏
• 举报

• 打赏
• 举报

``````select * from T1  t
where  not exists  (select 1 from T2 where rtrim(A)=rtrim(t.A) and  rtrim(B)=rtrim(t.B)) ``````
huangjianfen 2009-04-01
• 打赏
• 举报

[Quote=引用楼主 huangjianfen 的帖子:]

select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))
[/Quote]

select * from T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

htl258_Tony 2009-04-01
• 打赏
• 举报

``````select * from jam_T1 t
where  not exists  (select T1.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and  rtrim(T1.B)=rtrim(T2.B) and t.ID=t1.ID) ``````

mugua604 2009-04-01
• 打赏
• 举报

[code=SQL]
select A.* from T1 ,T2 where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B)
--这一步你已经查出有数据存在了

not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))
--这条语句实际上就等于 假了 也可以好比1=0

select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))
--所以不关jam_T1 里有多少数据
select * from jam_T1 where 1=0 永远都为空
[code]
htl258_Tony 2009-04-01
• 打赏
• 举报

[Quote=引用 1 楼 huangjianfen 的回复:]
select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

select * from jam_T1
where not exists (select T1.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))
[/Quote]

mugua604 2009-04-01
• 打赏
• 举报

``````

select * from jam_T1
where  not exists  (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and  rtrim(T1.B)=rtrim(T2.B))

select * from jam_T1  where 1<>1

false =not exists  (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and  rtrim(T1.B)=rtrim(T2.B))

``````
mugua604 2009-04-01
• 打赏
• 举报

``````

select * from jam_T1
where  not exists  (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and  rtrim(T1.B)=rtrim(T2.B))

select * from jam_T1  where 1<>1

false =not exists  (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and  rtrim(T1.B)=rtrim(T2.B))

``````
hyrongg 2009-04-01
• 打赏
• 举报

``````
select * from jam_T1
where  not exists  (
select 1 FROM T2
where rtrim(T2.A)=rtrim(T1.A) and  rtrim(T2.B)=rtrim(T1.B)
)
``````
huangjianfen 2009-04-01
• 打赏
• 举报

select * from jam_T1
where not exists (select A.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

select * from jam_T1
where not exists (select T1.* from T1 , T2
where rtrim(T1.A)=rtrim(T2.A) and rtrim(T1.B)=rtrim(T2.B))

22,210

• 近7日
• 近30日
• 至今