Solved

MySql Data Restore

Posted on 2011-09-14
2
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 60

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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