编辑
2023-09-26
后端
00
请注意,本文编写于 592 天前,最后修改于 581 天前,其中某些信息可能已经过时。

目录

总结

image.png

image.png

sql
create table Person( id int primary key, email varchar(20) ) ; <!-- more --> show tables; drop table Person; insert into Person values (1,'join@qq.com'),(2,'join@qq.com'),(3,'qwm@qq.com'); insert into Person values (5,'xwm@qq.com'); delete p1 from Person as p1,Person p2 where p1.email = p2.email and p1.id > p2.id; delete from Person where id not in (select id from (select min(id) as id from Person group by email) t); select p1.email from Person as p1, Person as p2 where p1.email=p2.email and p1.id!=p2.id group by p1.email; select email from Person group by email having count(email) > 1;

总结

  • group by + having解决重复小妙招

本文作者:yowayimono

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!