GsXtAsY Posted June 26, 2008 Share Posted June 26, 2008 ok i am going to try my best to explain what I need to do here...first off I need to add a new package to the website...the pkg_id = 86 What I need to do with that number is somehow in phpmyadmin add pkg_id = 86 to all accounts with the carrier_id = 6 now where this gets kinda confusing to me is the carrier_id is under the account table while pkg_id is under the accounts_pkgs table...is there a way to cross reference those two tables and then insert the new data into the accounts_pkgs table? and if so how would i go about writing that in SQL ??? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 say what? Quote Link to comment Share on other sites More sharing options...
GsXtAsY Posted June 27, 2008 Author Share Posted June 27, 2008 I knew this would be confusing...its so hard to explain what i need to do...in other words ill try this approach... I want to: SELECT `carrier_id`, `pkg_id` FROM `account`, `accounts_pkgs` WHERE carrier_id=6 Then on that return I want to insert pkg_id = 86 to all of those results Hopefully that makes more sense Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 By "insert" you mean update the matching rows? Quote Link to comment Share on other sites More sharing options...
GsXtAsY Posted June 27, 2008 Author Share Posted June 27, 2008 Thats correct...using INSERT I want to insert new rows to the accounts_pkgs table with all those that come up with the carrier_id = 6 Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 OK... so you need: INSERT INTO `accounts_pkgs` ( <column-list> ) SELECT <column-list> FROM `account` WHERE carrier_id=6 What will you be inserting? Quote Link to comment Share on other sites More sharing options...
GsXtAsY Posted June 27, 2008 Author Share Posted June 27, 2008 I will be inserting pkg_id = 86 along with the account_id...which is pulling from all the accounts that the carrier_id = 6 Quote Link to comment Share on other sites More sharing options...
GsXtAsY Posted June 27, 2008 Author Share Posted June 27, 2008 OK... so you need: INSERT INTO `accounts_pkgs` ( <column-list> ) SELECT <column-list> FROM `account` WHERE carrier_id=6 What will you be inserting? What do you mean by ( <column-list> )? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 Well, I mean the columns in the target table... 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.