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

  • SEARCH
  • Home
  • 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 6864343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:53:58+00:00 2026-05-27T02:53:58+00:00

I have a MySQL insert statement that inserts data from an existing Despgoods table

  • 0

I have a MySQL insert statement that inserts data from an existing
Despgoods table into a new table DespGoods_AllDetails. The primary key in both tables is ‘case no’ and the autoincrement column in despgoods_alldetails.

Each case number has a load number that changes from time to time. How can I adjust my statement so that when a duplicate key is detected, it simply updates the load number of that record rather than just fail/ ignore/ skip the record to be inserted. some records will not be duplicated and some will. The non duplicated records still need to be inserted whilst the duplicate records just need to be updated.

Do I use replace into or ON DUPLICATE KEY UPDATE? How do I use this syntax in my existing query?

insert ignore into despgoods_alldetails 
(`loc or exp` ,`LOC TRNSPRT DEST` ,`load number` ,`case no` ,`lot id` ,`metal mass` ,`gross mass` ,`CASE CREATION DATETIME` ,`CASE PROGERESS STATUS` ,`PROGRESS STAT DATETIME` ,`case width` ,`case height` ,`case length` ,`storage` ,`del prty` ,`CRTD DEPT` ,`CASE STATUS` ,`lab released` ,`PROD STREAM` ,`PROD SUB STREAM` ,`CSC Name` ,`Customer` ,`DAYS STANDING` ,`EXP SHIPREL` ,`LOC WHS EREL` ,`LOC CUST REL` ,`REC CHANGED AT` ,`transporttypename` ,`transporttypeid` ,`customerID`,`LOCStatus`)
SELECT `despgoods`.`loc or exp` ,`despgoods`.`LOC TRNSPRT DEST` ,`despgoods`.`load number` ,`despgoods`.`case no` ,`despgoods`.`lot id` ,`despgoods`.`metal mass` ,`despgoods`.`gross mass` ,`despgoods`.`CASE CREATION DATETIME` ,`despgoods`.`CASE PROGERESS STATUS` ,`despgoods`.`PROGRESS STAT DATETIME` ,`despgoods`.`case width` ,`despgoods`.`case height` ,`despgoods`.`case length` ,`despgoods`.`storage` ,`despgoods`.`del prty` ,`despgoods`.`CRTD DEPT` ,`despgoods`.`CASE STATUS` ,`despgoods`.`lab released` ,`despgoods`.`PROD STREAM` ,`despgoods`.`PROD SUB STREAM` ,`despgoods`.`CSC Name` ,`despgoods`.`Customer` ,`despgoods`.`DAYS STANDING` ,`despgoods`.`EXP SHIPREL` ,`despgoods`.`LOC WHS EREL` ,`despgoods`.`LOC CUST REL` ,`despgoods`.`REC CHANGED AT` ,`customers`.`transporttypename` ,`customers`.`transporttypeid` ,`customers`.`customerID` ,'loadplanned'
FROM despgoods
INNER JOIN customers
ON 
despgoods.customer = customers.customername
 ";
  • 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-27T02:53:59+00:00Added an answer on May 27, 2026 at 2:53 am

    You can use ON DUPLICATE KEY UPDATE for example :

    ...
    FROM despgoods
    INNER JOIN customers
    ON 
    despgoods.customer = customers.customername
    ON DUPLICATE KEY UPDATE `load number` = VALUES(`load number`);
    

    you can also use REPLACE INTO. The only thing is that it will delete the entire row and then insert.

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

Sidebar

Related Questions

I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`,
I have to insert some data into a MySQL table. The data will be
I have a class that inserts information into a MySQL database. I have the
I am trying to insert data from a csv file into mysql using BigDump.
Here's the thing, I don't have access to code that inserts data into a
I have two concurrent processes: 1.) Writer - inserts new rows into a MySQL
I have a mysql table that stores a mapping from an ID to a
I have multiple If statements that if true, inserts data into the db. The
I'd like to insert data into a mysql table using 'the cakephp way'. I
I have a MySql database that stores a timestamp for each record I insert.

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.