Finding duplicate values in MySQL

前端 未结 25 2517
执笔经年
执笔经年 2020-11-22 04:04

I have a table with a varchar column, and I would like to find all the records that have duplicate values in this column. What is the best query I can use to find the duplic

25条回答
  •  日久生厌
    2020-11-22 04:37

    For removing duplicate rows with multiple fields , first cancate them to the new unique key which is specified for the only distinct rows, then use "group by" command to removing duplicate rows with the same new unique key:

    Create TEMPORARY table tmp select concat(f1,f2) as cfs,t1.* from mytable as t1;
    Create index x_tmp_cfs on tmp(cfs);
    Create table unduptable select f1,f2,... from tmp group by cfs;
    

提交回复
热议问题