php - Delete double rows in MySQL table when columns have identical entries -


this question has answer here:

i have database table (test_table) auto-increment column (id) , want delete double (or more) entries when 3 specific columns (a, b, c) have identical entries.

    id    column_a    column_b    column_c ------------------------------------------------     1     ooo         aaa         uuu     2     ooo         aaa         uuu     3     ttt         ppp         uuu     4     ooo         aaa         uuu     5     iii         kkk         ccc 

in example, rows id 2 , 4 should deleted after executing delete query.

regards.

delete tbl `id` not in ( select * (                                 select min(`id`)                                  tbl                                 group `column_a`                                        , `column_b`                                        , `column_c`                                ) x               ) 

sqlfiddle


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -