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.
| Author |
Topic |
|
jpc82
Starting Member
8 Posts |
Posted - 2006-01-11 : 08:38:47
|
| I am working on an app using MS SQL and I am not sure how best to create a view I need. I have one table which has 3 fields ( user1, user2, user3), and another table which has two fields (userid, username).In my first table I want to store the user id's in the 3 fields, and then create a view which will have the actual username.egTable 2Userid UserName1------Mike2------John3------TomTable 1User1 User2 User31-----2-----3I want the view to haveUserid1 UserName1 Userid2 UserName2 Userid3 UserName31-------Mike------2-------John------3-------Tom |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-11 : 08:41:59
|
you can achieve using table aliasselect *from table1 t1 inner join table2 t2a on t1.user1 = t2a.useridinner join table2 t2b on t1.user2 = t2b.useridinner join table2 t2c on t1.user3 = t2c.userid -----------------'KH'Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. |
 |
|
|
jpc82
Starting Member
8 Posts |
Posted - 2006-01-11 : 08:57:14
|
| Thanks, that makes sence, I did't think of that. |
 |
|
|
|
|
|