I used one of these sql:
The code is as follows |
Copy Code |
UPDATE ' student_quiz_answer ' SET ' article_id ' = (SELECT qa.article_id, sqa.answer_id from Student_quiz_answer SQA left JOI N ' Quiz_answer ' qa on sqa.answer_id = qa.answer_id where qa.article_id > 0) |
When the problem comes from the MySQL Update table field, this error message is encountered if you have a Select of its own table in the update value:
#1093 –you can ' t specify target table ' Student_quiz_answer ' for update in FROM clause
However, the SQL Update value must also be queried based on the field of the current table.
The Update value is used as a new table, such as T2, and the table alias itself is T1. The conditional clause is that the association values for T1 and T2 are equal.
To implement the method correctly, you need to create an intermediate table with the contents of the middle table exactly the same as the FRJG table, then modify the FRJG table, the middle and FRJG tables have a "primary foreign key relationship" (no such relationship exists), and modify to such an SQL statement:
The code is as follows |
Copy Code |
UPDATE ' student_quiz_answer ' T1, (SELECT qa.article_id, sqa.answer_id from Student_quiz_answer SQA left JOIN ' Quiz_answer ' QA on sqa.answer_id = qa.answer_id where qa.article_id > 0 ' t2 SET t1. ' article_id ' = t2.article_id where t1.answer_id = t2.answer_id |
Summarize
1093 error: But when you modify a table, the subquery cannot be the same table, the solution: the handle query and then set a layer, into the original table grandson query on it, for example:
Insert into gg set id3= (select c.a+1 from (select Max (ID3) as a ) c) that's right. br> but insert into gg set id3= (select Max (ID3) as a from GG) will report a 1093 error