可能重复:
Remove duplicates in large MySql table
Can I extract the extract records that are duplicated in sql?
How can I delete duplicate rows in a table
我需要删除数据库中重复的行。
我发现使用此查询在表中重复了多少行:
SELECT GoodCode FROM Good_
这里是不同的查询SELECT Distinct GoodCode FROM Good_
第二个记录较低。请指导我如何从第一行中删除重复的行。
答案 0 :(得分:4)
简单方法:
SELECT DISTINCT *
INTO #TempGood
FROM Good_
TRUNCATE TABLE Good_
INSERT Good_
SELECT *
FROM #TempGood
DROP TABLE #TempGood
答案 1 :(得分:0)
create table temptable as select distinct * from Good_;
drop table Good_;
rename temptable to Good_;