Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have a table called Users, and another table called Transfers. In the Transfers table I have two user id fields specifying the person who did the transfer and the person who received it. How can I get both user names for a transfer eg. transferDate, FullNameOfPersonWhoDidTransfer, FullNameOfPersonWhoReceivedTransfer
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2010-06-16 : 13:47:08
Join Users table twice like
select a.transferDate,b.Name as [FullNameOfPersonWhoDidTransfer],c.Name as [FullNameOfPersonWhoReceivedTransfer]from Transfers ainner join Users b on b.NameID = a.NameIDofPersonWhoDidTransferinner join Users c on c.NameID = a.NameIDOfPersonWhoReceivedTransfer