Mysql执行删除语句
DELETE FROM agency WHERE id in(
SELECT b.id from agency b WHERE b.stateId in(
SELECT a.ID from states a WHERE a.saved=0 or a.saved=-1
)
)
出现You can't specify target table 'agency' for update in FROM clause错误,
解决方法:
DELETE FROM agency WHERE id in(
SELECT aaaa.id from(
SELECT b.id from agency b WHERE b.stateId in(
SELECT a.ID from states a WHERE a.saved=0 or a.saved=-1
)
) aaaa
)
也就是说将select出的结果再通过中间表select一遍