Back

mysql - 出现You can't specify target table for update in FROM clause错误的解决方法

发布时间: 2018-12-12 04:19:00

参考: https://blog.csdn.net/fdipzone/article/details/52695371

今天我的情况是:

dirty_ids = InstructorApplication.where('current_level
InstructorApplication.where( :id => dirty_ids ).delete_all  # 这样就会报错
dirty_instructor_application_ids.delete_all   # 这样就不会报错

解决办法很简单,就是 使用一个中间表来操作. 只有mysql有这个问题,oracle, mssql都不会.  

Back