问题:发现存在一张表中存在相同的两行数据

得到:仅仅保留一行数据

方法:

原理-我们通过

 1 select count (字段1,字段2) from 表1;
 2 
 3 结果 200条数据
 4 
 5 select count (distinct 字段1,字段2) from 表1;
 6 
 7 结果 100条数据
 8 
 9 相当于后者可以实现查出来去重后的数据
10 
11 create table 表1_bak as select distinct 字段1,字段2 from 表1;   --备份表数据
12 
13 delete from 表1;
14 
15 insert into 表1 select * from 表1_bak;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2021-04-01
  • 2021-08-14
  • 2021-12-31
相关资源
相似解决方案