mysql查询

warning: 这篇文章距离上次修改已过605天,其中的内容可能已经有所变动。
-- create table student(id int,name varchar(20),cource varchar(30),grade int);
-- insert into student value(2,'王五','English',100);
-- select * from student;
-- use test;

#查询所有name字段重复值 
-- select * from student where name in (select name from student group by name having count(name)>1) order by grade desc; 

#查询所有name字段重复值中id最小的
-- select * from student where name in(select name from student group by name having count(name)>1) and id in(select min(id) from student group by name having count(name)>1);
-- SET SQL_SAFE_UPDATES = 0;
-- delete from student where name in (select t.name from(select name from student group by name having count(name)>1) t) and id in (select dt.min_id from (select min(id) as min_id from student group by name having count(name)>1) dt);
none
最后修改于:2023年04月27日 16:13

已有 8 条评论

  1. 叼茂SEO.bfbikes.com

  2. 叼茂SEO.bfbikes.com

  3. 叼茂SEO.bfbikes.com

  4. 看的我热血沸腾啊https://www.jiwenlaw.com/

  5. 怎么收藏这篇文章?

  6. 不错不错,我喜欢看 https://www.237fa.com/

  7. 看的我热血沸腾啊https://www.ea55.com/

  8. 真棒!

添加新评论