更新时间:2022-12-11 23:21:47
INSERT INTO TARGET_TABLE SELECT * FROM SOURCE_TABLE;
编辑:如果表格具有不同的结构,您也可以:
INSERT INTO TARGET_TABLE(`col1`,`col2`)SELECT`col1`,`col2` FROM SOURCE_TABLE;
编辑:约束这个...
INSERT INTO TARGET_TABLE(`col1_`,`col2_`)SELECT`col1`,`col2` FROM SOURCE_TABLE WHERE`foo`= 1
/ pre>I am new to MySQL. I would like to copy the content of one table to another table within the same database. Basically, I would like to insert to a table from another table. Is there easy way of doing this?
INSERT INTO TARGET_TABLE SELECT * FROM SOURCE_TABLE;
EDIT: or if the tables have different structures you can also:
INSERT INTO TARGET_TABLE (`col1`,`col2`) SELECT `col1`,`col2` FROM SOURCE_TABLE;
EDIT: to constrain this..
INSERT INTO TARGET_TABLE (`col1_`,`col2_`) SELECT `col1`,`col2` FROM SOURCE_TABLE WHERE `foo`=1