MySQL数据库遇到字段冗余怎么办

2024-11-18 18:38:02
推荐回答(1个)
回答(1):

删除重复的记录(重复记录保留1条),可以按以下方法删除
seleet distinct * into #Tmp from TableName
drop table TableName
select * into TableName from #Tmp
drop table #Tmp

数据部分字段重复,ID不重复
delete 表 where id not in(
SELECT MAX(id) AS id FROM 表 GROUP BY rows) --- 删除重复行
select * from 表 where id in(
SELECT MAX(id) AS id FROM 表 GROUP BY rows) --重复行只查询一条