siamiam Posted December 6, 2011 Share Posted December 6, 2011 I'm using mySQL 5.5.9 and I'm attempting to insert data from one table into another. I have two tables, they both contain a column named 'chargify_id'. I need to copy the chargify_id from table1 into table2 for each entry where the user IDs match (user_id and ID) INSERT INTO table2 (chargify_id) SELECT chargify_id FROM table1 WHERE table1.user_id = table2.ID I feel like I'm close, but perhaps not. Quote Link to comment https://forums.phpfreaks.com/topic/252625-insert-multiple-with-where-clause/ Share on other sites More sharing options...
mikosiko Posted December 7, 2011 Share Posted December 7, 2011 you need an UPDATE with JOIN..... no INSERT http://dev.mysql.com/doc/refman/5.0/en/update.html Quote Link to comment https://forums.phpfreaks.com/topic/252625-insert-multiple-with-where-clause/#findComment-1295135 Share on other sites More sharing options...
siamiam Posted December 7, 2011 Author Share Posted December 7, 2011 I fixed it, thanks for your assistance mikosiko. You're awesome! Quote Link to comment https://forums.phpfreaks.com/topic/252625-insert-multiple-with-where-clause/#findComment-1295161 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.