自联结
删除emp_no重复的记录,只保留最小的id对应的记录。
https://www.nowcoder.com/practice/3d92551a6f6d4f1ebde272d20872cf05
delete t1
from titles_test t1,titles_test t2
-- where 两者员工id相等 and t1_id大于t2_id,do 删掉它们
where t1.emp_no = t2.emp_no
and t1.id > t2.id;
-- 显式
delete t1
from titles_test t1
-- 这里逻辑上是需要and而不是where,因为on + and 是一个完整条件,on + where 则是 on 后再 where
join tetles_test t2 on t1.emp_no = t2.emp_no and t1.id > t2.id