mysql删除重复记录
2017-06-16 11:01
197 查看
先查询重复记录值
select * from tbname where uid in (select uid from tbname group by uid having count(uid)>1);
能查询,应该就能删除
delete from tbname where uid in (select uid from tbname group by uid having count(uid)>1);
但是报错:You can't specify target table,意思是目标表不明确
修改sql语句,将查询结果放入一个临时表
delete from tbname where uid in (
select tmptb.uid(
select uid from tbname group by uid having count(uid)>1
) as tmptb
);
select * from tbname where uid in (select uid from tbname group by uid having count(uid)>1);
能查询,应该就能删除
delete from tbname where uid in (select uid from tbname group by uid having count(uid)>1);
但是报错:You can't specify target table,意思是目标表不明确
修改sql语句,将查询结果放入一个临时表
delete from tbname where uid in (
select tmptb.uid(
select uid from tbname group by uid having count(uid)>1
) as tmptb
);
相关文章推荐
- mysql 删除表中的重复记录,只保留其中一条
- MYSQL中删除重复记录的方法
- mysql删除重复记录语句的方法
- MySql删除重复的记录
- mysql删除重复记录,保留id最少
- MySQL 删除表中重复的记录(where......)
- MYSQL 删除同一表中重复记录
- MYSQL删除某个字段多余重复记录
- mysql删除重复记录语句的方法
- 删除MySQL表的重复记录
- MySQL查询及删除重复记录的方法
- MySQL重复记录 查询及删除
- mysql删除重复记录
- mysql,oracle里删除重复记录,只保留一条(除了自增长字段,其他的字段完全相同为相同记录)
- MYSQL中删除重复记录的方法
- MySQL查询及删除重复记录的方法
- MYSQL删除重复记录(此处有正解)
- MySQL语句删除数据库重复记录数据行
- MySQL查询及删除重复记录的方法
- 删除mysql重复记录的办法