MySQL: [Err] 1093, mysqlerr1093
The error means that some values in the same table cannot be selected before the table is updated (in the same statement ). For example, the following SQL statement:
Delete from tbl where id in
(
Select max (id) from tbl a where EXISTS
(
Select 1 from tbl B where a. tac = B. tac group by tac HAVING count (1)> 1
)
Group by tac
)
Rewrite it to the following:
Delete from tbl where id in
(
Select a. id from
(
Select max (id) id from tbl a where EXISTS
(
Select 1 from tbl B where a. tac = B. tac group by tac HAVING count (1)> 1
)
Group by tac
)
)
For example, UPDATE bk_ygsbk AS bk SET REPORT_VISIT = (select count (*) FROM bk_ygsbk where zyid = '1') WHERE bk. ZYID = '1'
UPDATE bk_ygsbk AS bk SET REPORT_VISIT = (SELECT * FROM (select count (*) FROM bk_ygsbk where zyid = '1') AS r) WHERE bk. ZYID = '1'
That is to say, the result of the select statement is then passed through the select statement in the middle table, thus avoiding errors. Note that this problem only occurs in mysql, and does not occur in mssql and oracle.