For example, I have several rows in a table (which I pulled from an XML of google products, so the same product is presented several times, each for a clothing / product size) that are referenced for the same item, only with product size difference, quantity and SKU code. In this table, I have a column that determines whether or not the product is displayed in the system (0 or 1). What I would like to do is to run a query that would check the duplicate items, changing the parameter of that column that makes the visualization available, hiding all duplicate items, leaving only one with the original value.
I was able to achieve something similar with the query below:
DELETE a FROM sis_produto_xml a LEFT JOIN ( SELECT MIN(ID) id, sku, nome FROM sis_produto_xml GROUP BY nome) b ON a.id = b.id AND a.sku = b.sku AND a.nome = b.nome WHERE b.id IS NULL;
The problem with this query is that it deletes the product, and then XML drops the same product again, that is, it is a work that has no end. Hiding the product through the table parameter (with an update instead of delete) would not happen.
Thank you guys.