SirChick Posted August 31, 2007 Share Posted August 31, 2007 Is there way to move a record from one table to another ... or will i just have to get row put each field data in a variable and then insert to a new row and delete old row? Kinda hoping theres a simple move feature to make life slightly quicker ? Quote Link to comment https://forums.phpfreaks.com/topic/67469-moving-a-record/ Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 You can just use a sub-query in place of the data. It would be something like: "INSERT INTO table2 (field1, field2, field3) VALUES ((SELECT field1 FROM table1 WHERE something = something), (SELECT field2 FROM table1 WHERE something = something), (SELECT field3 FROM table1 WHERE something = something))" Quote Link to comment https://forums.phpfreaks.com/topic/67469-moving-a-record/#findComment-338744 Share on other sites More sharing options...
roopurt18 Posted August 31, 2007 Share Posted August 31, 2007 That's pretty inefficient if all of the records are coming from the same row in the source table. INSERT INTO tblDest (dest1, dest2, dest3) SELECT src1, src2, src3 FROM tblSrc WHERE conditions Quote Link to comment https://forums.phpfreaks.com/topic/67469-moving-a-record/#findComment-338747 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.