要求 删除表中某字段重复记录,保留一条:
-- 做法,借用临时表
create table user_temp as
select a.name1,a.password1,MAX(a.ROWID) dataid from user_test1 a GROUP BY a.name1,a.password1;
-- 删除 重复记录
delete from user_test1 a
where a.rowid !=
(
select b.dataid from user_temp b
where a.name1 = b.name1 and
a.password1 = b.password1
);
commit;
有好的见意吗?
-- 做法,借用临时表
create table user_temp as
select a.name1,a.password1,MAX(a.ROWID) dataid from user_test1 a GROUP BY a.name1,a.password1;
-- 删除 重复记录
delete from user_test1 a
where a.rowid !=
(
select b.dataid from user_temp b
where a.name1 = b.name1 and
a.password1 = b.password1
);
commit;
有好的见意吗?