/* 群里的一个哥们问的问题,具体如下:
update a set bs='1' where x in(select x from a group by x having count(*)>1)
这个是给重复的数据都加赋值了1 我想留下重复中的一条不赋值,求高手指点
*/
SQL> select * from oraking;
ID NAME
---------- ----------
1 oraking
1 oraking
2 yallonking
2 yallonking
SQL> select * from oraking where rowid in (select max(rowid) from oraking group by id,name);
ID NAME
---------- ----------
1 oraking
2 yallonking
SQL> update oraking set name='小龙真帅' where rowid in (select max(rowid) from oraking group by id,name);
2 rows updated.
SQL> commit;
Commit complete.
SQL> select * from oraking;
ID NAME
---------- ----------
1 oraking
1 小龙真帅
2 yallonking
2 小龙真帅
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26143577/viewspace-719579/
,如需转载,请注明出处,否则将追究法律责任。