I have this query:
SELECT url_rewrite_id, COUNT(url_rewrite_id) FROM catalog_url_rewrite_product_category GROUP BY url_rewrite_id HAVING COUNT(url_rewrite_id) > 1;
Which returns some duplicate entries in my database. All entries are COUNT 2:
How can I combine to this the DELETE function so I can delete only 1 entry of each from my table?
I tried with:
DELETE url_rewrite_id, COUNT(url_rewrite_id) FROM catalog_url_rewrite_product_category GROUP BY url_rewrite_id HAVING COUNT(url_rewrite_id) > 1;
But I get error in mysql syntax:
Unexpected keyword. (near "GROUP BY" at position 87)
Unrecognized statement type. (near "GROUP BY" at position 87)
I also tried :
DELETE n1 FROM catalog_url_rewrite_product_category n1, catalog_url_rewrite_product_category n2 WHERE n1.url_rewrite_id > 1 AND n1.url_rewrite_id = n2.url_rewrite_id;
but this returns no entries.
Then tried:
DELETE n1 FROM catalog_url_rewrite_product_category n1, catalog_url_rewrite_product_category n2 WHERE n1.url_rewrite_id = n2.url_rewrite_id;
but this deletes all data from table
I can't figure out why is not working.
Any help please?