tobeyt23 Posted June 17, 2011 Share Posted June 17, 2011 I have 2 tables one that I update nightly from a data feed and the other that I use within my app. Trying to compare the nightly to the other and update with an additions or changes. How can I accomplish this? Quote Link to comment https://forums.phpfreaks.com/topic/239662-compare-tables/ Share on other sites More sharing options...
The Little Guy Posted June 17, 2011 Share Posted June 17, 2011 So do you want to have the updated table the exact same as the original table when the process is done? Quote Link to comment https://forums.phpfreaks.com/topic/239662-compare-tables/#findComment-1231197 Share on other sites More sharing options...
tobeyt23 Posted June 17, 2011 Author Share Posted June 17, 2011 I want the original to be update with any changes or updates that I pull into the nightly update Quote Link to comment https://forums.phpfreaks.com/topic/239662-compare-tables/#findComment-1231226 Share on other sites More sharing options...
ebmigue Posted June 18, 2011 Share Posted June 18, 2011 Assuming the two tables have are exactly the same (i.e., has the same attributes), then the classical Relational MINUS ought to do the trick. A MINUS B, would return the records of A that are not found in B. However, since that is not supported in SQL, you can simulate it using WHERE EXISTS, like so: SELECT * FROM nightly_feed WHERE NOT EXISTS( SELECT * FROM apps WHERE apps.field1 = nightly_feed.field1 AND apps.field2 AND nightly_feed.field2 (AND ..etc..) ) In short, use every attribute of the two tables/relvars. Hope it helps. Quote Link to comment https://forums.phpfreaks.com/topic/239662-compare-tables/#findComment-1231301 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.