数据库SQL实践42:删除emp_no重复的记录,只保留最小的id对应的记录

思路:

先找出每个emp_no中最小的id,若id不在最小id集合中则删除该记录。

delete from titles_test where id not in (select min(id) from titles_test group by emp_no);

delect from 表名 where 表达式。似乎不可以用group by等其他子句。

猜你喜欢

转载自blog.csdn.net/weixin_43160613/article/details/84643479