表A
col001 col002 col003
00123 aa 1.0
00122 bb 2.00
00111 cc 3.00
表B
col001 col002 col003
00123 aa 1.0
00122 bb 2.00
01123 aa 1.0
02122 bb 2.00
03123 aa 1.0
04122 bb 2.00现在我想表A的数据中的col001字段不在表B中取出来
select * from A where col001 not in (select col001 from B)这样一条也没取到?
这是为什么啊?
col001 col002 col003
00123 aa 1.0
00122 bb 2.00
00111 cc 3.00
表B
col001 col002 col003
00123 aa 1.0
00122 bb 2.00
01123 aa 1.0
02122 bb 2.00
03123 aa 1.0
04122 bb 2.00现在我想表A的数据中的col001字段不在表B中取出来
select * from A where col001 not in (select col001 from B)这样一条也没取到?
这是为什么啊?
where a.col001=b.col001看看这个能出来记录吗?
select col001 from B where col001 is null
http://topic.csdn.net/u/20110129/13/634be4df-ad97-405f-ae6f-3f04ea0b0f8c.html
--1
select *
from a
where co1001 not in (select isnull(co1001,'') from b)--2
select *
from A
where not exists(select 1 from B where col001=A.col001)
B表里面有为Null的值
select * from A where col001 not in (select col001 from B where col001 is not null )
即可