ZKX's LAB

sql求解答,重复数据删除 sql重复数据删除

2021-04-26知识10

SQL 删除重复数据 select distinct*into#Tmp_aa from tableName 把不重复的找出来插入到临时表drop table tableName 删掉原来的表select*into tableName from#Tmp_aa 把临时表插入到新建的tableNamedrop table#Tmp_aa 删掉临时表

求助SQL:如何删除重复数据 例如:记录虽然存在重复,但是rowid是唯一的,所以在子查询取得重复行中最小的rowid,删除重复行中大于最小的rowid的行,只是保留了最小rowid的行,就是删除了重复行。这个语句如果要调优的话,可以在内部查询中建索引delete from ttt a where rowid>;(select min(rowid)from ttt b where a.name=b.name);

sql求解答,重复数据删除 你数据库中没有唯一的用来区分这些数据行的字段么,比如自增长ID?如果没有就做不到,如果有的话,假定叫sysid,那你用select MAX(sysid),id,num from table1 group by id,num 就可以取到不重复的数据,用下面的可以删除其它多余的数据delete from table1 where sysid not in(select MAX(sysid)from table1 group by id,num)

随机阅读

qrcode
访问手机版