Error Code: 1093. You can't specify target table 'EMP' for update in FROM clause
时间: 2024-06-15 16:05:09 浏览: 155
Error Code: 1093 is a MySQL error that occurs when you try to update a table that is also used in the subquery of the update statement. Specifically, the error message "You can't specify target table 'EMP' for update in FROM clause" indicates that you are trying to update the 'EMP' table, but the same table is also referenced in the subquery.
To resolve this issue, you can use a workaround by creating a temporary table or using a nested subquery. Here's an example of how you can rewrite your query to avoid this error:
```
UPDATE EMP
SET column1 = value1
WHERE id IN (
SELECT * FROM (
SELECT id
FROM EMP
WHERE condition
) AS temp
);
```
In this example, we create a temporary table 'temp' using a nested subquery and then use it in the main update statement. This way, we avoid referencing the same table 'EMP' in the subquery.
阅读全文