我尝试使用以下代码插入多个语句
call
但是我收到了这个错误
错误代码:1054。'where子句'
中的未知列't1.name'
似乎在where子句中,insert into peoplePos
select a.name,b.option
FROM (SELECT name from people t1) a
JOIN (SELECT option FROM optionTable WHERE name = 'Position') b
where not exists (select * from peoplePos t2 where t2.name = t1.name);
无法访问之前声明的人t1
我尝试使用t1
和a.t1.name
,两者都不起作用
是否可以访问它?谢谢
答案 0 :(得分:1)
我认为你想要加入一些条件,但是根据你的要求,t1不存在。你把它别名为a使用。
insert into peoplePos
select a.name,b.option
FROM (SELECT name from people t1) a
JOIN (SELECT option FROM optionTable WHERE name = 'Position') b ON "SOME CONDITION OR OTHER"
where not exists (select * from peoplePos t2 where t2.name = a.name);