How do I INSERT INTO from one mysql table into another table and set the value of one column?

Posted by Laxmidi on Stack Overflow See other posts from Stack Overflow or by Laxmidi
Published on 2010-03-31T00:14:55Z Indexed on 2010/03/31 0:23 UTC
Read the original article Hit count: 648

Filed under:
|
|

Hi,

I need to insert data from table1 into table2. However, I would like to set the myYear column in table2 to 2010. But, there isn't a myYear Column in table1.

So, my basic insert looks like:

INSERT INTO  `table2` ( place, event ) 
SELECT place, event
FROM table1

Roughly, I'd like to do something like the following:

INSERT INTO `table2` ( place, event, SET myYear='2010' )
...

Is there a way to set the column value in the insert statement?

THANK YOU!

-Laxmidi

© Stack Overflow or respective owner

Related posts about mysql

Related posts about insert