比较SQL中的数据 [英] comparing data in sql

查看:134
本文介绍了比较SQL中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何比较两个不同表中的数据以找到不同的记录?

解决方案

您为什么要这么做?

为了有机会自动执行此操作,两个表必须具有相同的定义:两个表中的每个字段都必须完全相同.

那么,为什么要有两个相同且包含相同信息的表?

您可以尝试以下方法:

  SELECT  *  FROM  table1 在哪里  存在( SELECT  *  FROM  table2  WHERE  table1.Id = table2.Id)


您需要查询数据库...就这么全部

如何比较两个表-SQL Server [在SQL Server中比较两个表的最短,最快和最简单的方法:UNION! [^ ]

SQL Server 2005:使用EXCEPT和INTERSECT比较表 [ 解决方案

Why would you want to do that?

In order to have any chance of doing it automatically, the two tables would have to have identical definitions: every field in both tables must be exactly the same.

So why would you have two tables which are the same, and contain the same information?

You can try something along the lines of:

SELECT * FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE table1.Id = table2.Id)


You need to query the database...that''s all

How to compare two tables - SQL Server[^]

The shortest, fastest, and easiest way to compare two tables in SQL Server: UNION ![^]

SQL Server 2005: Using EXCEPT and INTERSECT to compare tables[^]


这篇关于比较SQL中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆