Skip to content

Instantly share code, notes, and snippets.

@manhdaovan
Last active March 17, 2017 01:52
Show Gist options
  • Save manhdaovan/11dfc7ec958042bb068e21e2c4fca980 to your computer and use it in GitHub Desktop.
Save manhdaovan/11dfc7ec958042bb068e21e2c4fca980 to your computer and use it in GitHub Desktop.
Remove duplicate rows on tables
/* Remove duplicate rows on table by simple query.
Repeate until no more query is removed */
delete from shop_product_price
where id in
(select tmp.id from
(select *, count(*) as num from shop_product_price
group by shop_id, product_id, price, min_quantity, shipping_fee
having num >= 2) as tmp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment