MySQL uses the create temporary table method to remove duplicate values in the data table

Source: Internet
Author: User

I checked a lot of data about removing duplicates from Mysql Data tables, and it is reliable to create temporary tables.

// Deduplication

$ Sql1 = "create temporary table tmp_table select * From tablename group by 'name '";
$ Pdo1-> exec ($ sql1 );
$ Sql2 = "Drop table tablename;
$ Pdo1-> exec ($ sql2 );
$ Sql3 = "create table tablename select * From tmp_table ";

$ Pdo1-> exec ($ sql3 );

Drop temporary table tmp_table

// Query duplicate data

Select user_name, count (*) as count from user_table group by user_name having count> 1;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.