sql - MySQL delete from query where two columns are duplicate -
what i'm looking do, delete duplicated column , column b duplicate. example:
a b c ----------------- apple pear 11 apple pear 12 apple pear 13 orange apple 22 orange beer 21 cinder punch 30 cinder punch 31 cinder punch 32 would result in:
a b c ----------------- apple pear 11 orange apple 22 orange beer 21 cinder punch 30
step 1: move non duplicates (unique tuples) temporary table
create table new_table select * old_table 1 group [column remove duplicates by]; here, [column remove duplicates by] = column names seperated "comma", in case a,b
step 2: delete delete old table no longer need table duplicate entries, drop it!
drop table old_table; step 3: rename new_table name of old_table
rename table new_table old_table;
Comments
Post a Comment