MySQL Error Code: 1093

Error as follows:

错误代码: 1093
You can't specify target table 'student_info' for update in FROM clause

Means: time for modifications to the table can not modify this table as a condition.

Solution: between the table and modify look-up table plus a layer query.

E.g:

/*错误SQL*/
DELETE FROM student_info WHERE id IN(
SELECT id FROM `student_info`)
/*正确SQL*/
DELETE FROM student_info WHERE id IN(
SELECT a.id FROM 
(SELECT id FROM `student_info`)a
)

Tip: The error is common in data deduplication operation, specifically refer to this blog ( related operations MySQL duplicated data (the case containing the primary key table does not exist) ).

 

Published 101 original articles · won praise 92 · views 60000 +

Guess you like

Origin blog.csdn.net/qq_39706570/article/details/104088030