petroz Posted July 29, 2010 Share Posted July 29, 2010 I have two tables of my vendor information. One has the addresses all on one cell, the other has all the info separated by address, city, state zip. I am trying to figure out how to update the new table with data from the old. Here is my query. UPDATE `vendors_test` SET `vendors_test`.`address_street` = (SELECT `old_vendors`.`vendors_addr1` from `old_vendors`) WHERE `vendors_test`.`id` = ( SELECT `old_vendors`.`vendors_id` FROM `old_vendors`) Mysql is saying "Subquery returns more than 1 row" and I am a little lost now... Any help or pointers would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/209260-trying-to-update-set-table1data-select-table2data/ Share on other sites More sharing options...
Mchl Posted July 29, 2010 Share Posted July 29, 2010 UPDATE vendors_test AS vt INNER JOIN old_vendors AS ov ON vt.id = ov.vendors_id SET vt.address_street = ov.vendors_addr1 Quote Link to comment https://forums.phpfreaks.com/topic/209260-trying-to-update-set-table1data-select-table2data/#findComment-1092730 Share on other sites More sharing options...
petroz Posted July 29, 2010 Author Share Posted July 29, 2010 Thanks! That did the trick! Quote Link to comment https://forums.phpfreaks.com/topic/209260-trying-to-update-set-table1data-select-table2data/#findComment-1092746 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.