user165242 user165242 - 3 months ago 7
MySQL Question

MYSQL: How to copy an entire row from one table to another in mysql with the second table having one extra column?

I have two tables with identical structure except for one column... Table 2 has that additional column in which i would insert the CURRENT_DATE()

I would like to copy all the values from table1 to table2.

if i use

INSERT INTO dues_storage SELECT * FROM dues WHERE id=5;

it throws an error pointing out to the difference in the number of columns.

I have two questions on that:

  1. How do I get around this?

  2. and how do I add the value for the additional date column (CURRENT_DATE()) in table2 within this same statement?


To refine the answer from Zed, and to answer your comment:

INSERT INTO dues_storage
FROM dues d
WHERE id = 5;

See T.J. Crowder's comment