|
id 自动编号 djh 单据号 sl 数量 表2 id 自动编号 djh 单据号 memo 备注 如何才能判断两张表中记录完全相同,如不同,是那几个记录不同,, 这个过程应该怎么写呢??谢谢 |
|
|
select * from 表1 where djh not in (select djh from 表2)
select * from 表2 where djh not in (select djh from 表1) |
|
|
|
Select * from 表1 a full join 表2 b on a.id = b.id
where a.id is null or b.id is null or a.djh is null or b.djh is null or a.memo is null or b.memo is null |
|
|
select * from 表1 where djh not in (select djh from 表2)
select * from 表2 where djh not in (select djh from 表1) 只判断了单据号,能判断两条记录完全相等吗?Table1.djh <> Table2.djh,那不就是不相等了,最少两条记录的djh字段不相等 |
|
|
表1有,表2无
select * from 表1 where not exists(select 1 from 表2 where 表1.djh=表2.djh) 表2有,表1无 select * from 表2 where not exists(select 1 from 表1 where 表1.djh=表2.djh) |
|
|
a.memo,表1没有memo字段
|
|