Skip to content

Instantly share code, notes, and snippets.

@mavvverick
Created August 1, 2016 13:27
Show Gist options
  • Save mavvverick/85df6850d82f16317884d28d111cb5e3 to your computer and use it in GitHub Desktop.
Save mavvverick/85df6850d82f16317884d28d111cb5e3 to your computer and use it in GitHub Desktop.
## Create temproray table by picking min duplicate id and delete
delete table from table inner join
(select min(id) minid, sample_data, sample_data1, sample_data2
from table
group by ssample_data, sample_data1
having count(1) > 1) as duplicates
on (duplicates.minid = search_search.id)
## Keep only duplicate entry and delete rest
delete table from table inner join
(select min(id) minid, sample_data, sample_data1, sample_data2
from table
group by sample_data, sample_data1
having count(1) > 1) as duplicates
on (
duplicates.sample_data = search_search.sample_data
duplicates.minid <> search_search.id
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment