我可以在MYSQL中连接两个表并创建一个新表

时间:2014-11-27 20:01:13

标签: mysql sql

如果可能的话,我想在加入这两个表之后创建一个新表

SELECT * FROM tablepeople
JOIN tableinfo
ON tablepeople.id = tableinfo.ctrlid

3 个答案:

答案 0 :(得分:3)

是的,您可以使用下面的CREATE TABLE AS ... SELECT FROM构造;考虑new_table已经存在

的事实
create table new_table as
SELECT * from tablepeople 
join tableinfo 
on tablepeople.id = tableinfo.ctrlid

答案 1 :(得分:0)

CREATE TEMPORARY TABLE [table_name] ( [query] );

OR

CREATE TABLE [table_name] ( [query] );

答案 2 :(得分:0)

您可以使用

创建表new_table

Create table new_table as
SELECT * FROM customers
LEFT JOIN orders ON customers.idcustomers = orders.idorders
UNION
SELECT * FROM customers
RIGHT JOIN orders ON customers.idcustomers = orders.idorders;