nikhilthecool Posted May 9, 2006 Share Posted May 9, 2006 purpose-want to make a duplicate of a record in the same table with few of the column values changedPS-there are more than 100 columns so treating them individually would be quite cumbersomeqry-> insert into table1 select * from table1 where xyz='abc'when i execute this qry i get a copy of the record whose xyz='abc' but there are certain columns which i need to change then itselfand what if there are certain unique fields?? what do i do then? Quote Link to comment https://forums.phpfreaks.com/topic/9370-mysql-query/ Share on other sites More sharing options...
fenway Posted May 10, 2006 Share Posted May 10, 2006 Well, with ~100 columns (!?!? -- this can't be good), INSERT INTO... SELECT WHERE seems out of the question -- you're not going to maintain such a huge column list. You could always just copy it and keep track of the LAST_INSERT_ID(), and update whatever needs updating, presumably <100 columns. Of course, as you alluded to, unique keys are going to be a problem. You might as well copy this to a dummy / temporary table, change the values, and then copy it back. Quote Link to comment https://forums.phpfreaks.com/topic/9370-mysql-query/#findComment-34939 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.