当前位置: 代码迷 >> PB >> 比较两个表中不同的数据,该怎么解决
  详细解决方案

比较两个表中不同的数据,该怎么解决

热度:78   发布时间:2016-04-29 09:52:37.0
比较两个表中不同的数据
我有两张表,表中都有上千条数据,表结构一模一样,只是不知道两张表中哪个字段中的数据不一样,导致汇总出来的结果不一致,找出数据不一致的记录

------解决方案--------------------
假设表A(col1, col2, col3) 表B(col1, col2, col3)

通过语句 select * from A where not exists(select 1 from B where B.col1 = A.col1 and B.col2 = A.col2 and B.col3 = A.col3) 来找出A表中不存在于B表的记录

通过语句 select * from B where not exists(select 1 from A where B.col1 = A.col1 and B.col2 = A.col2 and B.col3 = A.col3) 来找出B表中不存在于A表的记录
  相关解决方案