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

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -