1093 - You can't specify target table 'xxx' for update in FROM clause, Time: 0.002000s
根據結果集在b_order_copy1 表中刪除
DELETE FROM b_order_copy1 WHERE Id in ( SELECT Id FROM b_order_copy1 WHERE request_counts = 2 AND response_counts = 2 AND final_status = 200 AND create_time BETWEEN 1548000000000 AND 1548086400000 );
會出現1093 - You can't specify target table 'xxx' for update in FROM clause, Time: 0.002000s錯誤。(不能在同一語句中更新select出的同一張表中的屬性值)
mysql是不容許這樣操做的,須要經過一個子查詢的方式獲取到id。update語句同理。
解決方法:
DELETE FROM b_order_copy1 WHERE Id in ( SELECT a.Id FROM ( SELECT Id FROM b_order_copy1 WHERE request_counts = 2 AND
response_counts = 2 AND final_status = 200 AND create_time BETWEEN 1548000000000 AND 1548086400000 ) AS a );