Issue
I want to copy table1 to table2 except for the ‘id’ field because i want the ‘id’ in table2 to increment automatically.
Here is one of the solution i have tried… but not working:
“INSERT INTO table2 SELECT field1, field2, field3 FROM table1 WHERE member_id = ’53′”
Solution
You can select NULL in place of the id, if you don’t (for whatever reason) want to name the columns.
Assuming both of your tables have the columns member_id
, field1
, field1
, field3
, in that order, you can do:
insert into table2 select NULL, field1, field2, field3 from table1 where member_id = '53';
NOTE: you must provide a value for ALL columns, using this format.
Answered By – v4nz
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0