Click here to Skip to main content
15,918,243 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Query Performance question Pin
brdavid15-Aug-04 15:05
brdavid15-Aug-04 15:05 
GeneralRe: SQL Query Performance question Pin
Anonymous23-Aug-04 7:58
Anonymous23-Aug-04 7:58 
GeneralRe: SQL Query Performance question Pin
brdavid28-Aug-04 6:16
brdavid28-Aug-04 6:16 
QuestionC# SQL INSERT String??? Pin
gman4413-Aug-04 12:16
gman4413-Aug-04 12:16 
AnswerRe: C# SQL INSERT String??? Pin
Colin Angus Mackay13-Aug-04 12:47
Colin Angus Mackay13-Aug-04 12:47 
GeneralRe: C# SQL INSERT String??? Pin
gman4415-Aug-04 4:03
gman4415-Aug-04 4:03 
AnswerRe: C# SQL INSERT String??? Pin
S Sansanwal15-Aug-04 17:07
S Sansanwal15-Aug-04 17:07 
GeneralSELECT in UPDATE statement Pin
blopf13-Aug-04 9:28
blopf13-Aug-04 9:28 
Hello 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!

GeneralRe: SELECT in UPDATE statement Pin
Colin Angus Mackay13-Aug-04 12:50
Colin Angus Mackay13-Aug-04 12:50 
GeneralRe: SELECT in UPDATE statement Pin
blopf15-Aug-04 4:19
blopf15-Aug-04 4:19 
GeneralRe: SELECT in UPDATE statement Pin
Mike Dimmick15-Aug-04 9:11
Mike Dimmick15-Aug-04 9:11 
GeneralRe: SELECT in UPDATE statement Pin
EdbertP15-Aug-04 22:33
EdbertP15-Aug-04 22:33 
GeneralSQL Server 2005 Notification Services Pin
James Coleman13-Aug-04 7:50
James Coleman13-Aug-04 7:50 
GeneralComlex Query vs Multiple Queries Pin
iamalik13-Aug-04 6:41
professionaliamalik13-Aug-04 6:41 
GeneralRe: Comlex Query vs Multiple Queries Pin
Chris Meech13-Aug-04 6:49
Chris Meech13-Aug-04 6:49 
GeneralRe: Comlex Query vs Multiple Queries Pin
iamalik13-Aug-04 7:14
professionaliamalik13-Aug-04 7:14 
GeneralRe: Comlex Query vs Multiple Queries Pin
Colin Angus Mackay13-Aug-04 12:54
Colin Angus Mackay13-Aug-04 12:54 
GeneralRe: Comlex Query vs Multiple Queries Pin
Steven Campbell13-Aug-04 15:36
Steven Campbell13-Aug-04 15:36 
GeneralUpdate Database Pin
jzb13-Aug-04 6:12
jzb13-Aug-04 6:12 
GeneralRe: Update Database Pin
Colin Angus Mackay13-Aug-04 12:57
Colin Angus Mackay13-Aug-04 12:57 
Generalstart MSSQLServer Service from windows 98 Pin
Renjith Ramachandran13-Aug-04 1:07
Renjith Ramachandran13-Aug-04 1:07 
GeneralRe: start MSSQLServer Service from windows 98 Pin
Colin Angus Mackay13-Aug-04 3:46
Colin Angus Mackay13-Aug-04 3:46 
GeneralRe: start MSSQLServer Service from windows 98 Pin
Renjith Ramachandran13-Aug-04 5:26
Renjith Ramachandran13-Aug-04 5:26 
GeneralRe: start MSSQLServer Service from windows 98 Pin
Colin Angus Mackay13-Aug-04 13:09
Colin Angus Mackay13-Aug-04 13:09 
GeneralODBC Pin
lawred212-Aug-04 4:02
lawred212-Aug-04 4:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.