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 5991551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:24:12+00:00 2026-05-22T23:24:12+00:00

I have 2 tables, temporary and permanent table. My objective is to copy temporary

  • 0

I have 2 tables, temporary and permanent table.
My objective is to copy temporary data into permanent table but must update the permanant table.

Below are the tables

### Temp. table
CREATE TABLE `tb_temp_data` (
  `key_id` varchar(20) NOT NULL DEFAULT '',
  `h00` int(11) DEFAULT '0',  
  `h01` int(11) DEFAULT '0',  
  `h02` int(11) DEFAULT '0',  
  `h03` int(11) DEFAULT '0',  
  `h04` int(11) DEFAULT '0',  
  `h05` int(11) DEFAULT '0',  
  `h06` int(11) DEFAULT '0',  
  `h07` int(11) DEFAULT '0',  
  `h08` int(11) DEFAULT '0',  
  `h09` int(11) DEFAULT '0',  
  `h10` int(11) DEFAULT '0',  
  `h11` int(11) DEFAULT '0',  
  `h12` int(11) DEFAULT '0',  
  `h13` int(11) DEFAULT '0',  
  `h14` int(11) DEFAULT '0',  
  `h15` int(11) DEFAULT '0',  
  `h16` int(11) DEFAULT '0',  
  `h17` int(11) DEFAULT '0',  
  `h18` int(11) DEFAULT '0',  
  `h19` int(11) DEFAULT '0',  
  `h20` int(11) DEFAULT '0',  
  `h21` int(11) DEFAULT '0',  
  `h22` int(11) DEFAULT '0',  
  `h23` int(11) DEFAULT '0',
  `grand_total` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`key_id`)
) ENGINE=MyISAM;

### Permanant table
CREATE TABLE `tb_permanant_data` (
  `key_id` varchar(20) NOT NULL DEFAULT '',  
  `h00` int(11) DEFAULT '0',  
  `h01` int(11) DEFAULT '0',  
  `h02` int(11) DEFAULT '0',  
  `h03` int(11) DEFAULT '0',  
  `h04` int(11) DEFAULT '0',  
  `h05` int(11) DEFAULT '0',  
  `h06` int(11) DEFAULT '0',  
  `h07` int(11) DEFAULT '0',  
  `h08` int(11) DEFAULT '0',  
  `h09` int(11) DEFAULT '0',  
  `h10` int(11) DEFAULT '0',  
  `h11` int(11) DEFAULT '0',  
  `h12` int(11) DEFAULT '0',  
  `h13` int(11) DEFAULT '0',  
  `h14` int(11) DEFAULT '0',  
  `h15` int(11) DEFAULT '0',  
  `h16` int(11) DEFAULT '0',  
  `h17` int(11) DEFAULT '0',  
  `h18` int(11) DEFAULT '0',  
  `h19` int(11) DEFAULT '0',  
  `h20` int(11) DEFAULT '0',  
  `h21` int(11) DEFAULT '0',  
  `h22` int(11) DEFAULT '0',  
  `h23` int(11) DEFAULT '0',
  `grand_total` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`key_id`)
) ENGINE=MyISAM;

INSERT INTO tb_permanant_data 
       SELECT * FROM  tb_temp_data ;
       ON DUPLICATE KEY UPDATE h00 = ?

I want to make sure all h00 until h23 will be updated by adding the value into tb_permanant_data but i have no idea on how to do that…

Can anyone help?

Thanks

  • 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-22T23:24:13+00:00Added an answer on May 22, 2026 at 11:24 pm
    INSERT INTO tb_permanant_data SELECT * FROM tb_temp_data 
    ON DUPLICATE KEY UPDATE 
      h00 = VALUES(h00),
      h01 = VALUES(h01),
      h02 = VALUES(h02),
      h03 = VALUES(h03),
      h04 = VALUES(h04),
      h05 = VALUES(h05),
      h06 = VALUES(h06),
      h07 = VALUES(h07),
      h08 = VALUES(h08),
      h09 = VALUES(h09),
      h10 = VALUES(h10),
      h11 = VALUES(h11),
      h12 = VALUES(h12),
      h13 = VALUES(h13),
      h14 = VALUES(h14),
      h15 = VALUES(h15),
      h16 = VALUES(h16),
      h17 = VALUES(h17),
      h18 = VALUES(h18),
      h19 = VALUES(h19),
      h20 = VALUES(h20),
      h21 = VALUES(h21),
      h22 = VALUES(h22),
      h23 = VALUES(h23);
    

    Note, table tb_permanant_data can contain rows which doesn’t exist in tb_temp_data (by id).

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

Sidebar

Related Questions

I have a query that creates several temporary tables and then inserts data into
I have three tables which I want to combine into one view or temporary
I have a SQL file with temporary tables creation, some load data infile, some
I have the following tables: create temporary table Items (item_id int, item_name varchar(10)); create
I have to create a temp tables...But the problem is if multiple user will
I've never used the Global Temporary Tables however I have some questions how they
I have a temporary table (or, say, a function which returns a table of
I have a temporary table that I'm using and I have a unique column,
I have a temporary table that contains a part category and the associated part
I have problems filling a temporary table with the resultset from a procedure call

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.