[Solved] MYSQL Error: You can’t specify target table for update in FROM clause

You can’t specify target table for update in from clause in MySQL. This error means that you can’t select some values of the same table in the same SQL statement before updating the table. (not the same table)

Then execute to update the content of the first message of each user to Hello world

Because in the same SQL statement, select the minimum ID value of each user message in the message table first, and then update the message table, error 1093 (HY000): you can’t specify target table ‘message’ for update in from claim will appear.

Solution: select the result through an intermediate table again to avoid this error (including delete)

Modify after where condition

Note that only MySQL has this problem, and neither MSSQL nor Oracle has this problem.

Similar Posts: