Solved

MySql Data Restore

Posted on 2011-09-14
2
217 Views
Last Modified: 2012-05-12
I recently had to restore a backup and to say the least it went bad.  I have missing records.  I now have two tables one is a good backup of the originally lost data (loanFindingReplace) and a live table that has some, but not all of the original findings.  I can not just replace the current live table (loanFinding) since I have had number entries since the restore.  How is the easiest/quickest query to determine which records don't exist in the loanFinding table that do exist in the loanFindingReplace table and insert those into loanFinding?  Both tables have the same fields with the same names.  Fields
Thank you.
0
Comment
Question by:rcowen00
2 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 36540868
Hi.

Sorry to hear about the failed restore. That can be a pain in the tail. To answer your question, I would start with a NOT EXISTS clause.

It works in general as:

SELECT {column list}
FROM TableA
WHERE NOT EXISTS (
   -- don't need to actually return data, so literal 1 is fine.
   SELECT 1 
   FROM TableB
   WHERE TableB.UniqueColumn = TableA.UniqueColumn
)
;

Open in new window


In your case, that may look like:
SELECT loanFindingKey
FROM loanFindingReplace r
WHERE NOT EXISTS (
   SELECT 1
   FROM loanFinding l
   WHERE l.loanFindingKey = r.loanFindingKey
)
;

Open in new window


Note: you may need to look at some other data that identifies a match if it is possible that you have duplicate auto_number values for non-matching rows due to the data lost. If not, then should be as simple as above.

Hopefully that helps!

Kevin
0
 

Author Closing Comment

by:rcowen00
ID: 36540963
Thank you.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mysqli Query 5 48
phpMyAdmin simple sql statement 3 53
Closing database connection after prepared statement 1 44
setup wamp server for first time 2 46
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now