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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:29:34+00:00 2026-05-24T08:29:34+00:00

Ok, the title may be difficult to understand, but this is what I want

  • 0

Ok, the title may be difficult to understand, but this is what I want to do.

I have a Table ‘A’ with a few columns.
I have a Table ‘B’ with the exact same columns.

During my program flow, I insert a few rows from ‘A’ into ‘B’ (sort of a temp cache).
Column data in ‘A’ may change, but when someone clicks the ‘restore’ button, I wanna copy those rows from ‘B’ back into ‘A’ and overwrite those rows with the same id as the ones i want to copy from ‘B’.

E.g.

Table A:

1  :      Hi |
2  :      Friends |
3  :      What's up

During the flow i backup id 1 and 2

Table B:

1  :      Hi |
2  :      Friends

Now I do some stuff and table A changes a bit

Table A (changed):

1 :       Hi diddely doo |
2 :       Amigo's |
3 :       What's up 

Now I realise my changes are wrong, and I want to put the records with id 1 and 2 back in their original state, from table ‘B’.

Is there a ‘simple’ sql to do that, without fetching those id’s 1 by 1 and update it 1 by 1?

Thanks in advance!

  • 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-24T08:29:35+00:00Added an answer on May 24, 2026 at 8:29 am

    You can use JOIN in UPDATE statements:

    UPDATE ta SET ta.text = tb.text
    INNER JOIN tb ON ta.id = tb.id
    

    Or with implicit join:

    UPDATE ta, tb SET ta.text = tb.text
    WHERE ta.id = tb.id
    

    You can delete and reinsert, that way you don’t have to specify columns if both tables have the same table scheme:

    DELETE FROM ta WHERE id IN (SELECT id FROM tb)
    
    INSERT INTO ta
    SELECT * FROM tb
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Title may not describe what I actually want, but I hope this is not
The title may have been confusing, but please let me explain: Currently when I
I understand the title may be a little vague, but, hopefully, I can explain
my title may not be clear. But basically what I want to do is:
My title may make my question sound confusing, but it is not. I have
The question's title may sound stupid, but I have beenw wondering about the following
The title may sound odd, but im kind of trying to set up this
The title may have said enough but I'll explain it anyway: My application gets
This title may sound a little bit crazy, but this is what is making
The title may be a bit vague, but here's my goal: I have a

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.