我正在尝试根据更多连接表更新一个表列,如下面的查询,
update building
set name = 'Payment'
where id in (select id
from
(select b.id
from t1 d
join t2 dl
join t3 a
join t4 f
join t5 b on d.id = dl.id
on a.id = dl.id
on a.id = f.id
on b.id = f.id
where d.deviceId='002') as id);
我收到错误:
错误代码:1064。您的SQL语法有错误;检查与MySQL服务器版本相对应的手册,以便在a.floorId = f.id上的a.id = dl.areaId附近使用正确的语法b.id = f.buildingId其中d.deviceId = ' 022''在第1行
但是当我更改下面的查询时,
update building
set name = 'Payment'
where id in (select id from
(select b.id from t1 d join t2 dl join t3 a join t4 f join t5 b where d.id=dl.id and a.id=dl.id
and a.id=f.id and b.id=f.id and d.deviceId='022') as id);
它按照我的预期正常工作。所以我在第一个查询中出错了?
我知道这个子查询不利于性能,所以请告诉我进行此更新的好方法。