Platinumweaver Posted January 28, 2009 Share Posted January 28, 2009 MYSQL: 5.0.67 Level of Confidence: LOW two tables share data posts contains post_id, topic_id, forum_id topics contains topic_id, forum_id My problem is that the process I used to convert the data from one forum software to another has backfired and left posts.forum_id blank (default value - 0). I can manually go through and edit every value of posts.forum_id to match up with the appropriate topics.forum_id because posts.topic_id and topics.topic_id are the same, but I am hoping that someone can save me the hours of manual work with a short mysql query that can look up topics.forum_id for each instance of posts.topic_id and write the correct values back into posts.forum_id Any help would be greatly appreciated, Thanks, PW. Quote Link to comment https://forums.phpfreaks.com/topic/142857-solved-duplicate-information-from-one-table-to-another-a-better-way/ Share on other sites More sharing options...
Mchl Posted January 28, 2009 Share Posted January 28, 2009 UPDATE posts AS p, topics AS t SET p.forum_id = t.forum_id WHERE p.topic_id = t.topic_id (untested) Quote Link to comment https://forums.phpfreaks.com/topic/142857-solved-duplicate-information-from-one-table-to-another-a-better-way/#findComment-748900 Share on other sites More sharing options...
Platinumweaver Posted January 28, 2009 Author Share Posted January 28, 2009 Tested. Worked. Confirmed. Fantastic work, thank you so much, you just saved me 70,000 entries worth of work. Quote Link to comment https://forums.phpfreaks.com/topic/142857-solved-duplicate-information-from-one-table-to-another-a-better-way/#findComment-748917 Share on other sites More sharing options...
Mchl Posted January 28, 2009 Share Posted January 28, 2009 you just saved me 70,000 entries worth of work. That feels good Cheers! P.S. There's 'Mark as Solved' button somewhere below. Click it. Quote Link to comment https://forums.phpfreaks.com/topic/142857-solved-duplicate-information-from-one-table-to-another-a-better-way/#findComment-748928 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.