Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/weixin_39207535/article/details/88547757
When del Mysql and update with sub-queries will be reported this wrong
-> Because in MYSQL, the recording can not first select a table, then under these conditions to update and delete records in the same table
The solution is , select the results obtained, and then select it again by the middle of the table, so that you avoid the error,
This problem only occurs in mysql, mssql and oracle problem does not occur
For more details, see sql:
The original error sql:
UPDATE table_A SET status=1
WHERE A_id IN(
SELECT order_id FROM table_A_B WHERE B_id=23
)
After modifying sql:
UPDATE table_A SET status=1
WHERE A_id IN(
SELECT a.id FROM (
SELECT id FROM table_A_B WHERE B_id=23
) a)
The equivalent of internal sub-cycle played an alias