Like what:
UPDATE Test.tb_vobile A
Set a.name = ' 111 '
WHERE
a.ID = (select Max (ID) ID from test.tb_vobile)
Error:
[SQL] UPDATE Test.tb_vobile A
Set a.name = ' 111 '
WHERE
a.ID = (select Max (ID) ID from test.tb_vobile)
[ERR] 1093-you can ' t specify target table ' a ' for update in FROM clause
The following are available by:
UPDATE Test.tb_vobile A
Join
(select MAX (ID) ID from test.tb_vobile) b
On a.id = b.ID
Set a.name = ' 123 ';
Or
UPDATE Test.tb_vobile A, (select MAX (ID) ID from test.tb_vobile) b
Set a.name = ' 321 '
WHERE
a.ID = b.id;
Description
1, update, the updated table cannot be used in the set and where in the subquery;
2, update, multiple tables can be updated (SQL Server does not work);
such as: Update Ta a,tb b set a.bid=b.id, b.aid=a.id;
3, after the update can do arbitrary query, this role is equivalent to from;
MySQL Database update updates subquery