delete duplicate rows on pgsql and mysql

This code shows how to delete duplicate rows on pgsql 

 

DELETE

FROM
m_product

WHERE

sku in(

SELECT
sku

FROM
(
SELECT
sku,
count(*)

FROM
m_product

GROUP BY
sku

HAVING count(*) > 1
) a
)

AND em_mg_manufacturer = 1000012

 

In MYSQL

DELETE
product

FROM
product

WHERE

reference in (

SELECT
reference

FROM
(
select
reference,
count(*)

from
product

GROUP BY reference

having count(*) > 1) a)

AND
product.id_manufacturer = 309

Leave a Reply

Your email address will not be published. Required fields are marked *