Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 JOIN Question

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2005-09-30 : 11:48:04
I have 3 basic tables joined like this and there are many responses in tblResponses related to each original request in tblRequests. When a new response is added in tblResponses, I insert the UserID (int) value in tblResponses. When a want to display the user's name associated with that response (not the UserID), how do I do this? This statement below gives me the name in the original request in tblRequests and I want the user's name in tblResponses. Sorry if this is confusing...Thanks.


SELECT tblUsers.name, tblResponses.response, tblResponses.ID
FROM tblRequests INNER JOIN
tblResponses ON tblRequests.ReqID=tblResponses.ReqID INNER JOIN
tblUsers ON tblRequests.UserID=tblUsers.UserID
WHERE tblResponses.ReqID=1

tblUsers
_________
Name
UserID

tblRequests
___________
ReqID
UserID


tblResponses
______________
ReqID
UserID
Response

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-09-30 : 12:08:15
[code]SELECT tblUsers.name, tblResponses.response, tblResponses.ID
FROM tblRequests INNER JOIN
tblResponses ON tblRequests.ReqID=tblResponses.ReqID INNER JOIN
tblUsers ON tblResponses.UserID=tblUsers.UserID
WHERE tblResponses.ReqID=1[/code]That's elementary, i think you rushed to much to post the question on the forum. Fortunatelly it's Friday.
Go to Top of Page

evanburen
Posting Yak Master

167 Posts

Posted - 2005-09-30 : 12:30:40
Now that I see the answer, I think you're right

Thanks.
Go to Top of Page
   

- Advertisement -