这样查询就不会出现重复记录了。
select * from a
union select * from b
union select * from c 再者,你是删除联合表中的重复记录,可是你要删除哪个表中的记录呢。
还有就是你的单个表中有重复记录吗?
select * from a
union select * from b
union select * from c 再者,你是删除联合表中的重复记录,可是你要删除哪个表中的记录呢。
还有就是你的单个表中有重复记录吗?
解决方案 »
- 求助!Oracle 最新时间查询语句 如何转换成SQL2005语句?
- 此会话中的事务活动已由另外一个会话提交或终止
- 求一难度的SQL语句
- 关于一个SQL语句写法的问题,Update表中的一个字段~~着急~在线等~
- 把前几天和 j9988 讨教的问题贴出来
- 如何捡索出几个表中某个记录值相等的所有记录????
- varchar型转换成Datetime型,可以吗,怎么做?
- 请给个模糊查询的存储过程示例!
- 为什么这个语句在SQLSERVER查询分析器中能正确查询,但在WEB 网页中用此语句会出现问题
- 怎样在存储过程中用关键字IN?
- 大家好请大家给个思路:从一个系统中两个表里的数据导入到另一个系统中的一个表里,这两个表的结构不一样.
- 从Excel往sqlserver导数据的问题
union select distinct * from b
union select distinct * from c
有可能A表和B表中的某一条记录相同
或者
A表自身的二条记录重复
或者
A表和C表中的某一条记录相同
就必须删除不管中哪个表中的一条
identity(int,1,1) as row,d.*
into #t
from
(select * from a union all select * from b union all select * from c) d
select d.* from #t d where not exists(select 1 from #t where idcard=a.idcard and row<a.row)
identity(int,1,1) as row,d.*
into #t
from
(select * from a union all select * from b union all select * from c) d
select d.* from #t d where not exists(select 1 from #t where idcard=d.idcard and row<d.row)
数据库中已存在名为 '#t' 的对象。
delete b where idcard in (select distinct idcard from a union selet distinct idcard from c)
delete c where idcard in (select distinct idcard from a union selet distinct idcard from b)
不知道是不是你想要的