scotchegg78 Posted August 18, 2008 Share Posted August 18, 2008 Hi guys. I am updating a new counties for companys table and it uses a new reference table, so new ids etc. currently I have tables ... company_region (companyfk,regionfk) region(id,name) the new tables are for ease... new_company_regions(companyid,countyid) new_regions(id,countyname) So how can I take from the current company_regions table the companyfk and insert this into new_company_region.compnayid with a new countyid where new_regions,countyname matches the old region.name ? I think this makes sense?? Thanks for any help, just getting a little sticky with it. Link to comment https://forums.phpfreaks.com/topic/120168-mulitple-insert-from-table/ Share on other sites More sharing options...
Hooker Posted August 18, 2008 Share Posted August 18, 2008 I'm not sure i quite understand but as best as i can, you want to take the contents of "company_region" and put it in "new_company_regions"? if so, something like this might do it: INSERT INTO new_company_regions (companyid,countyid) SELECT company_region.companyfk, company_region.regionfk FROM company_region; Link to comment https://forums.phpfreaks.com/topic/120168-mulitple-insert-from-table/#findComment-619274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.