如何编写一个mysql查询,将读取数据从一个表和写信给另一个?How do I write a mysql query that will read data from one table and write to another?

- 此内容更新于:2014-12-30
主题:

如果这是可能的,请提供一个或两个示例查询,所以我可以看到它如何工作。两个表将在同一个数据库中。 谢谢!

原文:

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!

解决方案:
伪编码:
原文:

Pseudo code:

insert into <target-table>
( <column-list> )
select <columns>
  from <source-table>
解决方案:
插入……答案是选择;参见http://dev.mysql.com/doc/refman/5.1/en/insert-select.html。 例如:
原文:

INSERT...SELECT is the answer; see http://dev.mysql.com/doc/refman/5.1/en/insert-select.html.

For example:

INSERT INTO names
SELECT last_name, first_name
FROM people