Updating multiple databases

Rated 3.90/5 based on 893 customer reviews

Hi Site Point members I have been perusing through the solutions for "updating multiple rows with one query", but I have a pressing question: How would one "SET" multiple column values with one query?Here is my example..normal update command would be: // question ID ranges from 1-20 // $questionid == 1, $member_id==1 UPDATE table_Foo Bar SET answer One='$ans1Val', answer Two='$ans2Val', answer Three='$ans3Val' WHERE member_id='$memberid' AND question_id='$questionid'; // $questionid == 2, $member_id==1 UPDATE table_Foo Bar SET answer One='$ans1Val', answer Two='$ans2Val', answer Three='$ans3Val' WHERE member_id='$memberid' AND question_id='$questionid'; ..However, if you're updating two or more related tables, include all the update logic within a transaction.A transaction is a process that assures that all related changes to a database are successful before any changes are committed.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).r397 recommended to have the three rows in a normalized table, in first normal form. Now if there was a Member #1 Responses - Question #1: yes, 22, no, 34 - Question #2: no, 24, yes, 42 - Question #3: yes, 14, no, 42 Member #2 Responses - Question #1: no, 42, no, 55 - Question #2: no, 51, yes, 21 - Question #3: yes, 11, no, 14 etc., I see your concern and how you may recommend having only one answer for one question, which makes it so much easier to update SQL and PHP wise!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.- The database must contain a record of answers made by all users- Every "Item" has 4 answers associated with them, (for now...)- There can be any number of "items" listed on a single survey page (in this screenshot, I only show 3 items, but there may be up to 20 or 30 items that have to be listed)- "Value Saved" has a HIDDEN constant that gets calculated with the "Test Value" entered.

updating multiple databases-24

updating multiple databases-85

Thing is, there have been no concerns about normalization as I have had no problems with data insertion, querying results, reporting the answers, association of answers with members, etc!This step creates a data source from the Northwind database using the Data Source Configuration Wizard.You must have access to the Northwind sample database to create the connection.This walkthrough shows how to add code to save updates from more than one table.The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or the edition that you're using.

Leave a Reply