I noticed that I have a lot of duplicates in one of my tables. Here's an example of how the table looks (example with one id_product_attribute number):
So I want to delete the duplicate currencies for EACH id_product_attribute. The desired result is to have one id currency for each id_product_attribute. Which means: 1, 2, 3, 4, 6 --> 5 rows per id_product and not 10 (5 duplicates).
I tried to use different codes but I can't make it work:
DELETE FROM product_attribute USING product_attribute, product_attribute pa
WHERE product_attribute.id_currency > pa.id_currency
AND product_attribute.id_product_attribute = pa.id_product_attribute
AND product_attribute_price.id_product_attribute = '16632'
So If I run the above, I will delete everything and only id_curreny 1 will stay there. I need to have:
Attribute Currency
16632 - 1
16632 - 2
16632 - 3
16632 - 4
16632 - 6
Can anyone help me with this? Any hint would be much appreciated.
Thank you