如果可能的话,我想把这两个表连接起来后再做一个新表
SELECT * FROM tablepeopleJOIN tableinfoON tablepeople.id = tableinfo.ctrlid
SELECT * FROM tablepeople
JOIN tableinfo
ON tablepeople.id = tableinfo.ctrlid
44u64gxh1#
是的,你可以像下面这样使用CREATE TABLE AS ... SELECT FROM结构;考虑到new_table并不存在
CREATE TABLE AS ... SELECT FROM
new_table
create table new_table asSELECT * from tablepeople join tableinfo on tablepeople.id = tableinfo.ctrlid
create table new_table as
SELECT * from tablepeople
join tableinfo
on tablepeople.id = tableinfo.ctrlid
编辑:
根据最新的评论,使用表别名来解决这个问题
CREATE TABLE mytable3 ASSELECT t1.* FROM mytable1 t1 JOIN mytable2 t2 ON t1.ID=t2.ID
CREATE TABLE mytable3 AS
SELECT t1.*
FROM mytable1 t1
JOIN mytable2 t2 ON t1.ID=t2.ID
mepcadol2#
您可以使用新建表new_table
Create table new_table asSELECT * FROM customersLEFT JOIN orders ON customers.idcustomers = orders.idordersUNIONSELECT * FROM customersRIGHT JOIN orders ON customers.idcustomers = orders.idorders;
Create table new_table as
SELECT * FROM customers
LEFT JOIN orders ON customers.idcustomers = orders.idorders
UNION
RIGHT JOIN orders ON customers.idcustomers = orders.idorders;
juzqafwq3#
此查询将连接两个表并使用这两个连接的表创建新表
Syntex: select * into new_table_nameFrom table1 as t1Join table2 as t2 ON t2.column name = t1.column name;Example: select * into emp_detlsFrom employee as empJoin employeeDOB AS edob ON edob.employeeID = emp.e_id
Syntex: select * into new_table_name
From table1 as t1
Join table2 as t2 ON t2.column name =
t1.column name;
Example: select * into emp_detls
From employee as emp
Join employeeDOB AS edob ON edob.employeeID
= emp.e_id
8yparm6h4#
CREATE TEMPORARY TABLE [table_name] ( [query] );
或
CREATE TABLE [table_name] ( [query] );
4条答案
按热度按时间44u64gxh1#
是的,你可以像下面这样使用
CREATE TABLE AS ... SELECT FROM
结构;考虑到new_table
并不存在编辑:
根据最新的评论,使用表别名来解决这个问题
mepcadol2#
您可以使用
新建表new_table
juzqafwq3#
此查询将连接两个表并使用这两个连接的表创建新表
8yparm6h4#
或