dflow Posted July 21, 2010 Share Posted July 21, 2010 i have an old DB where i had a requests table now in the new DB i can create several proposals per each request. what im trying to do is create a proposal per each request with a specific statusID in other words copy the request data with StatusID=4 into the proposals table as a new proposal the tables have the schema besides primarykey RequestID in the Requests_tbl and ProposalsID in the Proposals_tbl how should i approach this?? Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/ Share on other sites More sharing options...
Barand Posted July 21, 2010 Share Posted July 21, 2010 You could use an INSERT query INSERT INTO propasal (a,b,c) SELECT (a,b,c) FROM request WHERE StatusID = 4 Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089102 Share on other sites More sharing options...
dflow Posted July 21, 2010 Author Share Posted July 21, 2010 You could use an INSERT query INSERT INTO propasal (a,b,c) SELECT (a,b,c) FROM request WHERE StatusID = 4 (a,b,c) are the fields? if so what's the insert all syntax? Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089119 Share on other sites More sharing options...
dflow Posted July 21, 2010 Author Share Posted July 21, 2010 You could use an INSERT query INSERT INTO propasal (a,b,c) SELECT (a,b,c) FROM request WHERE StatusID = 4 how can I correlate between same name fields in the tables ? Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089147 Share on other sites More sharing options...
Barand Posted July 22, 2010 Share Posted July 22, 2010 If the record formats are identical in both tables, the "all" syntax is INSERT INTO proposal SELECT * FROM request WHERE StatusID = 4 Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089461 Share on other sites More sharing options...
dflow Posted July 22, 2010 Author Share Posted July 22, 2010 the fields arent identical but most have same names , how would i make the same name fields inserted ? Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089562 Share on other sites More sharing options...
Barand Posted July 22, 2010 Share Posted July 22, 2010 See my original post Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089579 Share on other sites More sharing options...
dflow Posted July 22, 2010 Author Share Posted July 22, 2010 See my original post i get an error #1241 - Operand should contain 1 column(s) INSERT INTO proposals (proposals.RequestID, proposals.CustomerFirstName) SELECT (contact_form.RequestID, contact_form.CustomerFirstName) FROM contact_form WHERE StatusID = 2 Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1089591 Share on other sites More sharing options...
dflow Posted July 23, 2010 Author Share Posted July 23, 2010 bump really intriged Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1090115 Share on other sites More sharing options...
fenway Posted July 25, 2010 Share Posted July 25, 2010 Drop the parens around your select column list. Quote Link to comment https://forums.phpfreaks.com/topic/208416-copy-records-and-create-new-record-query/#findComment-1090930 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.