对没有索引的字段进行查询重复时如果使用select name from table where name in(select name from table group by name having count(name)>1)这类查询,效率非常低,是不可取的,下面给出替代步骤:

1.根据重复记录创建临时表

create table   temptable as (

   select title from video

    GROUP BY title HAVING count(title) >1

);

2.查询重复数据

select a.* from temptable t,video a where a.title=t.title;

 

下面给出实际中我使用的删除重复数据的脚本,供参考:

create table   temptable as (

   select MAX(id) as id  from video

    GROUP BY title HAVING count(title) >1

);
delete  from video where id in (select id from temptable) order by id ;
drop table temptable;

 

相关文章:

  • 2021-08-17
  • 2022-01-03
  • 2021-11-25
  • 2022-01-04
猜你喜欢
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-10-10
  • 2021-06-06
相关资源
相似解决方案