What’s wrong with this picture?
mysql> update ignore flight set intl=1 where id in (select f.id as id from flight f left join airport a on a.id=f.origin where a.country<>'mx' for update);
ERROR 1093 (HY000): You can't specify target table 'flight' for update in FROM clause
This construct is invalid in mySQL
According to the manual,
You can use a subquery for assignment within an UPDATE statement because subqueries are legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot use the same table (in this case, table t1) for both the subquery’s FROM clause and the update target.
The equivalent multi-table update does the same and works as intended:
update flight f left join airport a on a.id=f.origin set f.intl=1 where a.country<>'mx';
gracias yo se q alguien tendria q decir algo razonable para resolverlo
This really works….
Thanks
:)