0
我有一张表,我想在其中插入数据,并且值本身必须来自多个表。这必须做如下,通过阅读MySQL文档:插入到多个选择
insert into flight(airlinecompanyId,planetypeId)
select id from airlinecompany where naam = 'Brussels Airlines',
select id from planeType where type = 'Boeing 737';
所以,简单地解释,我想插入的ID从表中的airlinecompany和planetype,我通过地方clausule要求,到飞行表列。
当我尝试此查询,我不断收到以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' select id from planeType where type = 'Boeing 737'' at line 2
谁的人有一个解决方案吗?
如何这两个表('airlinecomapny,planetype')有关吗?您要插入两列 - 两张表的id是否完全相同? –
他们没有关系,但airlineCompanyId和planetypeId都是航班表中的外键,如果这就是你的意思? – Programmer1994
那你的目标是什么?如果'planeType'和'airlinecompany'不相关,你是否试图为这两个值插入一行? –