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. Quote Link to comment 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; Quote Link to comment 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.