select count(*) as 记录数 from 表1 a left join 表2 b on a.字段a=b.字段a and a.字段b=b.字段b and a.字段c=b.字段c and b.字段 is null
select a.* from 表1 a left join 表2 b on a.字段a=b.字段a and a.字段b=b.字段b and a.字段c=b.字段c where b.字段a is null
1楼: b.字段 is null 写在on里面错的
--假设表一和表二有三个字段 a,b,c--在表一中有的再表二中没有的 select * from b1 where not exists(select * from b2 where b1.a=b2.a and b1.b=b2.b and b1.c=b2.c) --在表二中有的再表一中没有的 select * from b2 where not exists(select * from b1 where b1.a=b2.a and b1.b=b2.b and b1.c=b2.c)
from 表1 a left join 表2 b
on a.字段a=b.字段a and a.字段b=b.字段b and a.字段c=b.字段c and b.字段 is null
on a.字段a=b.字段a and a.字段b=b.字段b and a.字段c=b.字段c
where b.字段a is null
b.字段 is null 写在on里面错的
select *
from b1
where
not exists(select * from b2 where b1.a=b2.a and b1.b=b2.b and b1.c=b2.c)
--在表二中有的再表一中没有的
select * from b2
where
not exists(select * from b1 where b1.a=b2.a and b1.b=b2.b and b1.c=b2.c)