题解 |删除表中的特定行

删除emp_no重复的记录,只保留最小的id对应的记录。

https://www.nowcoder.com/practice/3d92551a6f6d4f1ebde272d20872cf05

不能直接用delete from  titles_test where id=....
要新增一个临时表delete t1 from titles_test as t1 left join ...
delete t1 from titles_test as t1  left join (select  emp_no,min(id) as min_id from titles_test group by emp_no) tt on t1.emp_no=tt.emp_no where t1.id<> tt.min_id;
		

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务