Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4613804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:36:23+00:00 2026-05-22T01:36:23+00:00

I have two identical tables, one with current values for rows, and one with

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:36:24+00:00Added an answer on May 22, 2026 at 1:36 am

    Use:

    SELECT n.item_id
      FROM NEW_ITEMS n
     WHERE EXISTS (SELECT NULL
                     FROM OLD_ITEMS o
                    WHERE o.item_id = n.item_id
                      AND (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 all of the columns being compared.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two identical tables and need to copy rows from table to another.
I have two tables with identical structure except for one column... Table 2 has
I have two tables and I'm looking for the rows in one table where
Let's say I have two databases with identical tables, but one database's tables contains
I have two tables with identical fields that share many rows. I'd like to
There are two tables: table A and table B. They have the same columns
I am trying to copy data from an old database into a new one,
I have a script that appends some rows to a table. One of the
I have two tables with identical fields, 35 identical fields. I know I can
I have two arrays of System.Data.DataRow objects which I want to compare. The rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.