This is simple problem, but I feel like there should be an elegant solution. I have had a script which works by using this statement:
insert into table1 select * from table2 where pk = "'.$pk.'";
Recently I want to add a column to the end of table1 which is a timestamp column with default value now(). This generally works and I was expecting to not have to change the above statement, but if I add the new timestamp column, the above statement will fail with the following error:
column count doesn't match value count
insert into jobticket.flatdestroyed (col1,col2) select col1,col2,.....So select the columns other than the timestamp on and insert into should have the columns other than the timestamp and if its set default as current timestamp it should do what you want.table1that I want to add the column to. Only reason is there are like 100 columns... guess I'm just being lazy.