Poddy Posted February 14, 2008 Share Posted February 14, 2008 Hi, i currently have an html form which is supposed to send data inserted into the database, the problem is that i want to insert values in an exiting row created earlier while the values i want to insert are currently null if i insert the entire row it works fine.. the table is built as the following: user_id q1 q2 q3 q4 12345 ans1 ans2 ans3 ans4 i have tried using the INSERT INTO table WHERE user_id='12345' (q1, q2, q3, q4) VALUES (val1, val2, val3, val4) but it dosent work, however if i add the user id WITH the other values is works.. but this is not what i want it to do... i want to have a database of users id's and when they answer on forms questions that data is sent to the database as the following.. should i use the update command instead? even that they are null if so how can i update multiple fields together in the same update query? Quote Link to comment Share on other sites More sharing options...
aschk Posted February 14, 2008 Share Posted February 14, 2008 INSERT is for new records. (hence you cannot use a WHERE clause). UPDATE is for existing records. Therefore you should be doing: UPDATE table SET q1='val1', q2='val2', q3='val3', q4='val4' WHERE user_id='12345' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.