MySQL Query更新多个表

I have a Quiz module in which I have two tables quiz_question and quiz_options. quiz_question is saving Questions and quiz_option saving options for particular questions.

table structure for quiz_option: id | question_id | text | is_correct

table structure for quiz_question id | title | desctiption |

Where question_id is foreign key to id of quiz_question

I want to write a query to update quiz_question and all its corresponding quiz_options is a single query.

enter image description here

try this

UPDATE  table1 a
        INNER JOIN table2 b
            ON a.ID = b.ID
SET     a.value = b.value 

Multiple table update you can use foreign key connect two and more table with foreign key concept update parent table primary key to child table foreign key see link http://www.hostingadvice.com/how-to/mysql-foreign-key-example/.

table quiz_question PK (question_id)
table quiz_option FK (question_id)

Get the id of the question and Update them one by one as you cannot update two tables using a single query.

$ID_VALUE = mysqli_real_escape_string($conn, $_GET['id']);
UPDATE quiz_option SET fields_name = 'value' WHERE question_id = $ID_VALUE;
UPDATE quiz_question SET fields_name = 'value' WHERE id = $ID_VALUE;

Here is the query:

INSERT INTO quiz_question(title,description) VALUES ('test','test question'); 
INSERT INTO quiz_option(question_id,text,is_correct) VALUES (LAST_INSERT_ID(),'test','0'),(LAST_INSERT_ID(),'test2','0'),(LAST_INSERT_ID(),'test3','0'),(LAST_INSERT_ID(),'test4','1')