What I mean is that if I do the select with an select into statement it will create a new table for me with the result. I dont have an update statement, because all the ones I tried generates errors :(
blopf
Posts
-
SELECT in UPDATE statement -
SELECT in UPDATE statementHello All, I have a problem that I cannot seem to solve. My guess is that I am thinking wrong. The problem is probably really simple but I cannot seem to solve it. I have two tables, one called test_user and one called test_answer. (Below all types in the tables are integers) test_user looks like this: user_id,time_answered,+some other statistics 1 0 2 0 3 0 test_answer looks like this: test_id,user_id,answered 0 1 1 0 2 1 0 3 0 1 1 1 1 2 1 1 3 0 3 1 1 3 2 0 3 3 0 Basicly test_answered contains a 1 in the answered if the user has answered a question on test test_id. What I want to do is sum up all the answers and update the test_user table. If I do this SQL-query then I get the table I want to update test_user with. select user_id,sum(answered) as sum from test_answer where answered = 1 group by user_id (The output will be: user_id,sum 1 3 2 2 ) Is there a simple way to update the test_user tables without doing a select into (and destroying all other data I have in the table.) As I told you this is probably an super simple question but I cannot get it right? hope you guys can help me!