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

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

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

MySQL is not allowed to delete record with selecting action. So the point of this problem is rebuilding a new chart for next step of deleting.

DELETE FROM titles_test
WHERE id NOT IN (
    SELECT * FROM(
    SELECT MIN(id)
    FROM titles_test
    GROUP BY emp_no
) as A
)
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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