Updating rows in mysql
btw, why did you make up ficticious table names and then add the explanation?you really ought to help make it easier for poeple to try to help you.A more effective solution to this problem is to attempt to reduce the number of UPDATE statements.
The only thing I am trying to solve is updating the database with one query instead of (1 to N) number of insert queries depending on how many "items" are listed.
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).
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.Back to my original question: How would I format a CASE Statement query to update the database?