Jim R Posted December 5, 2011 Share Posted December 5, 2011 I'm hoping writing down my issue will help me find the logic in it. I have two tables in two different databases that are essentially the same. I've updated each separately at different times without remembering I had two of them. Now I'm trying to merge information from the email columns. These are coaching jobs which have changed since last year. There were around 90 changes. I'm trying to move the emails I have in t2 that I don't have in t1. I have NULL cells in both columns, and I don't want to overwrite emails I already have in t1 with NULL cells I have in t2. I need something that Sets t1.email Where t1.email isn't equal to t2.email and t2.email Is Not Null. (I should have done this before I changed the coaches' names. I could have used that as a trigger.) Would that be the logic? I definitely need help with the syntax. UPDATE jwrbloom_hhr.hhr_schools t1 JOIN jwrbloom_hhm.schools t2 ON t1.id = t2.id SET t1.email = t2.email WHERE ?????? Quote Link to comment https://forums.phpfreaks.com/topic/252486-merging-similar-columns-from-different-databases/ Share on other sites More sharing options...
Jim R Posted December 5, 2011 Author Share Posted December 5, 2011 Crap, that easy enough. UPDATE jwrbloom_hhr.hhr_schools t1 JOIN jwrbloom_hhm.schools t2 ON t1.id = t2.id SET t1.email = t2.email WHERE t2.email IS NOT NULL Quote Link to comment https://forums.phpfreaks.com/topic/252486-merging-similar-columns-from-different-databases/#findComment-1294612 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.