If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database.
如果可以,请提供一两个示例查询,以便我了解它是如何工作的。两个表都在同一个数据库中。
Thanks!
2 个解决方案
#1
12
Pseudo code:
insert into <target-table>
( <column-list> )
select <columns>
from <source-table>
#2
4
INSERT...SELECT
is the answer; see http://dev.mysql.com/doc/refman/5.1/en/insert-select.html.
INSERT ... SELECT就是答案;请参阅http://dev.mysql.com/doc/refman/5.1/en/insert-select.html。
For example:
INSERT INTO names
SELECT last_name, first_name
FROM people
#1
12
Pseudo code:
insert into <target-table>
( <column-list> )
select <columns>
from <source-table>
#2
4
INSERT...SELECT
is the answer; see http://dev.mysql.com/doc/refman/5.1/en/insert-select.html.
INSERT ... SELECT就是答案;请参阅http://dev.mysql.com/doc/refman/5.1/en/insert-select.html。
For example:
INSERT INTO names
SELECT last_name, first_name
FROM people