这算什么事:
update tableName1 as tb1 set tb1.columnName1=newValue where tb1.id=(
select tb3.id from tableName2 as tb2 inner join tableName1 as tb3 on tb2.tableName1_id=tb3.id where tb2.id=11
)
报错:
Error Code: 1093. Table 'tableName1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
但是,查询嵌套子查询是可以用的:
select tb1.* from tableName1 as tb1 where tb1.id=(
select tb3.id from tableName2 as tb2 inner join tableName1 as tb3 on tb2.tableName1_id=tb3.id where tb2.id=11
)
为解决这个问题,我暂时的解决办法是将修改语句嵌套的子查询拿出来单独做一次查询,但是这存在查询性能(效率)问题。