1,group by方法

查数据:

  

select count(num), max(name) from student --列出重复的记录数,并列出他的name属性 
  group by num 
  
having count(num) >1 --按num分组后找出表中num列重复,即出现次数大于一次 


删数据:
  

1 delete from student 
2   group by num 
3   having count(num) >1

  这样的话就把所有重复的都删除了。


2,用distinct方法 -对于小的表比较有用

1 create table table_new as  select distinct *  from table1 minux 
2 truncate table table1;
3 insert into table1 select * from table_new;




 

相关文章:

  • 2021-07-28
  • 2021-07-22
  • 2022-12-23
猜你喜欢
  • 2021-07-11
  • 2021-11-17
  • 2021-08-15
  • 2022-01-05
  • 2022-12-23
  • 2021-11-09
  • 2022-01-26
相关资源
相似解决方案