日期:2014-05-18  浏览次数:20461 次

怎么删除两个表中相同的数据?
怎么删除两个表中相同的数据?
表中分别有一列,有相同的数据,我想删除其中一个表中的数据

------解决方案--------------------
怎么删除两个表中相同的数据?
表中分别有一列,有相同的数据,我想删除其中一个表中的数据
------------------------
delete t
where id in(select id from t1)
------解决方案--------------------
delete 表A
from 表A,表B
where 表A.列=表B.列
------解决方案--------------------
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
应该是删除表中重复记录?
------解决方案--------------------
select distinct *
from 表1
union all
select distinct *
from 表2
group by 字段
having count(*)> 1

以上是用来找出表1和表2共有记录的
加distinct 是为了把表1和表2自身重复的行去掉,如果都没有重复的,那可以不加
------解决方案--------------------
楼上正解!!