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
 General SQL Server Forums
 New to SQL Server Programming
 Translating multiple user guids to display name

Author  Topic 

k00tje
Starting Member

2 Posts

Posted - 2009-09-30 : 02:56:50
Hi All,

I'm having an issue where i do have tables like this:

Table1
userguid1
userguid2
userguid3

Table2
guid
displayname

In table1 all columns display a guid and can differ.
How can i replace the userguid with the displayname in my query ?

It did cost me pretty much time so far trying with multiple joins, but couldn't figure out what i'm doing wrong.
Probably a piece of cake for you guys.

Thanks for reading

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-30 : 03:05:38
[code]
select
t1.userguid1,
g1.displayname,
t1.userguid1,
g2.displayname,
t1.userguid1,
g3.displayname
from Table1 t1
left join Table2 g1 on t1.userguid1 = g1.guid
left join Table2 g2 on t1.userguid2 = g2.guid
left join Table2 g3 on t1.userguid3 = g3.guid
[/code]


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

k00tje
Starting Member

2 Posts

Posted - 2009-09-30 : 03:20:39
Wow, that did the trick.
Thank you very much.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-30 : 03:25:09
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -