I have two identical tables, one with current values for rows, and one with new values. I am trying to select only the rows from the new values table where any column in the new values table has a different value than the column in the old values table. The query I am using now looks like:
SELECT `new`.`item_id`
FROM `new_items` AS `new`
JOIN `items` AS `old`
WHERE new.item_id = old.item_id
AND (new.price != old.price ||
new.description != old.description ||
new.description_long != old.description_long ||
new.image_small != old.image_small ||
new.image_large != old.image_large ||
new.image_logo1 != old.image_logo1 )
However, this query takes WAY too long to execute. Does MySQL have a better way to do this or does anyone know a more efficient query?
Use:
Index all of the columns being compared.