我有兩個表一個是問題和其他是答案。用內部連接更新兩個表
問表具有領域
question_id, question, type, answer_id.
回答表具有領域
answer_id, question_id, comment, rating, doctor_id
現在我想更新的答案屬於發問,doctor_id。爲此,我試着寫這個查詢:
update question q
set q.question = 'dmvvnnv',a.comment = 'covonfvk',a.rating = 5
INNER JOIN answer a on q.answer_id = a.answer_id
WHERE a.doctor_id = 8
但它給我的語法錯誤:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN answer a on q.answer_id = a.answer_id WHERE a.doctor_id = 8' at line 1
的可能的複製[使用MySQL:使用內部連接的值更新場(http://stackoverflow.com/questions/14006856/using-mysql-update -field-with-values-using-inner-join) – jpw
另外,https://stackoverflow.com/questions/8057565/mysql-update-statement-inner-join-tables?noredirect=1&lq=1這本來是一個更好的欺騙目標。 – jpw