mysql - Join two identical tables on rows with different values -


i have 2 identical tables, 1 current values rows, , 1 new values. trying select rows new values table column in new values table has different value column in old values table. query using looks like:

select `new`.`item_id`    `new_items` `new`    join `items`  `old`   new.item_id = old.item_id    , (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, query takes way long execute. mysql have better way or know more efficient query?

use:

select n.item_id   new_items n  exists (select null                  old_items o                 o.item_id = n.item_id                   , (o.price <> n.price                    or o.description <> n.description                     or o.description_long <> n.description_long                     or o.image_small <> n.image_small                     or o.image_large <> n.image_large                     or o.image_logo1 <> n.image_logo1)) 

index of columns being compared.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -