Updating rows in mysql
table_member ( member_id, taking Foobar, foobar Completed, foobar Start Time, foobar End Time ) //foobar is actually a "results" table.;) table_foobar ( foobar_id, member_id, question_id, answer One, answer Two, answer Three, answer Four ) //Multiple questions for a single foobar Main survey.For small numbers of rows requiring updates, it can be adequate to use an UPDATE statement for each row that requires an update.
The dominant factor in the time taken to complete the overall operation tends to be the “admin” work in conveying the application’s intention to the database server rather than the actual updates to the database.But we can group the updates according to the value being set, and then do one UPDATE statement per distinct value.In this case there are two distinct values, so we can do it in two UPDATE statements: So we can reduce the number of queries from five to two. But the extent to which this helps us reduces as the proportion of distinct SET values goes up.There are other issues but, I got confused with the table names.bazz My answers are in one table (table_foobar), and does use a FK(question_id) to relate them to the questions table (table_questions).