[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 481
  • Last Modified:

update query two identical tables one to one relationship

HELP! I'm trying to restore data that was inadvertently deleted from a table with data from a backup table. I need to update the fields in tblBooks1 with the data in the fields in tblBooksonly284 for all records in tblBooksonly284.

I tried this query, but am getting pop-ups that are asking for parameter values for all tblBooksonly284 fields.

I tried earlier but negleted to add the WHERE clause, and it deleted ALL data from all of these fields,  I had backed up the data, so am trying again.

What am I doing wrong?  
The identical field is an autonumber field.  Hopefully it's possible to join those fields.

UPDATE tblBooks1 SET tblBooks1.YrWritten = tblBooksonly284!YrWritten, tblBooks1.NoPages = tblBooksonly284!NoPages, tblBooks1.Summary = tblBooksonly284!Summary, tblBooks1.GenreID = tblBooksonly284!GenreID, tblBooks1.[Film Title] = tblBooksonly284!FilmTitle, tblBooks1.FilmDate = tblBooksonly284!FilmDate, tblBooks1.FilmDetails = tblBooksonly284!FilmDetails, tblBooks1.Subjects = tblBooksonly284!Subjects
WHERE tblBooks1.BookID  = tblBooksonly284.BookID;

Thanks.
0
schneider_ks
Asked:
schneider_ks
  • 2
1 Solution
 
schneider_ksAuthor Commented:
PS, I should add that the tblBooks1 has 1200 records, and the tblBooksonly284 has only 284 records.  The rest of the records were inadvertently deleted.
0
 
PaulstottCommented:
Try

UPDATE tblbooks1 INNER JOIN tblbooksonly284 ON tblbooks1.bookID = tblbooksonly284.bookID SET tblbooks1.yrwritten = tblbooksonly284.yrwritten, tblbooks1.nopages = tblbooksonly284.nopages, tblbooks1.summary = [tblbooksonly284].[summary] ......... etc
0
 
Arthur_WoodCommented:
or:

UPDATE tblBooks1,tblBooksonly284  SET tblBooks1.YrWritten = tblBooksonly284!YrWritten, tblBooks1.NoPages = tblBooksonly284!NoPages, tblBooks1.Summary = tblBooksonly284!Summary, tblBooks1.GenreID = tblBooksonly284!GenreID, tblBooks1.[Film Title] = tblBooksonly284!FilmTitle, tblBooks1.FilmDate = tblBooksonly284!FilmDate, tblBooks1.FilmDetails = tblBooksonly284!FilmDetails, tblBooks1.Subjects = tblBooksonly284!Subjects
WHERE tblBooks1.BookID  = tblBooksonly284.BookID;


AW
0
 
schneider_ksAuthor Commented:
Excellent.  Problem Solved.  Thanks for the quick fix
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now