1. select a.* from 表AAA where Cast(ID as varchar(1000)) not in (select Cast(ID as varchar(1000)) from 表BBB)2. select a.* from 表BBB where Cast(ID as varchar(1000)) not in (select Cast(ID as varchar(1000)) from 表AAA)
select a.* from 表AAA where ID not in (selectID from 表BBB) select a.* from 表BBB where ID not in (select ID from 表AAA)
1、表AAA中有,表BBB中没有的记录有哪些? ------------------------------------- select * from AAA where ID not in (select ID from BBB); 2、表BBB中有,表AAA中没有的记录有哪些? ------------------------------------- select * from BBB where ID not in (select ID from AAA);
id 不用是字符型也可以用 in
1:SELECT * FROM AAA WHERE ID NOT IN (SELECT ID FROM BBB) 2:SELECT * FROM BBB WHERE ID NOT IN (SELECT ID FROM AAA)
(select Cast(ID as varchar(1000)) from 表BBB)2.
select a.* from 表BBB where Cast(ID as varchar(1000)) not in
(select Cast(ID as varchar(1000)) from 表AAA)
select a.* from 表BBB where ID not in (select ID from 表AAA)
-------------------------------------
select * from AAA where ID not in (select ID from BBB);
2、表BBB中有,表AAA中没有的记录有哪些?
-------------------------------------
select * from BBB where ID not in (select ID from AAA);
2:SELECT * FROM BBB WHERE ID NOT IN (SELECT ID FROM AAA)