Forum Moderators: open
I have 3 tables
1. tblUsers - Fields include UserID and ClientID
2. tblUserSurveyResponses - Fields include UserID and UserSurveyResponses
3. tblClients - Fields include ClientID
The asp.net page has a grid that pulls all clients (select * from clients)
I have a button on the grid that passes the clientID to another page called ViewUserResponses.aspx ( /viewuserresponses.aspx?clientid=22 )
How do I take that ClientID and select all UserSurveyResponses with it given the above mentioned tables?
My logic and way of thinking says this is a 2 part statement.
1st Part - Get all UserID's where ClientID = passed-in-query-string-variable-clientid
2nd Part - Get all UserSurveyResponses where usersurveyresponses.UserID = list-of-userids-from-1st-Part
Obviously if you could help me out with syntax it would be appreciated.
Thanks,
Mike.
I don't know ASP/.NET, so I can't help you with the exact syntax, but you could get the results with a single query:
SELECT usr.*
FROM tblUserSurveyResponses usr inner join tblUsers u on usr.UserID = u.UserID inner join tblClients c on u.ClientID = c.ClientID
WHERE c.ClientID = 12345
Of course, the exact syntax would change depending on your table/field names, etc., but hopefully that will point you in the right direction.
Chad