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 |
|
portrman
Starting Member
24 Posts |
Posted - 2003-07-31 : 19:38:00
|
| So I have table A with say uid, owner_id, creator_idtable B has uid, usernameI am currently doing a join likeSELECT a.uid, a.owner_id, b.username AS owner_str, a.creator_idFROM aLEFT OUTER JOIN b ON a.uid = b.uidBut now I've added the a.creator_id and need to join again with b to get the username for that column. How would I do that?I would like to add something such asb.username AS creator_str but that always returns the same as owner_strThanks |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2003-07-31 : 19:50:15
|
| hi, do you mean this?SELECT a.uid, a.owner_id, b.username AS owner_str, c.username as creator_strFROM aLEFT OUTER JOIN b ON a.uid = b.uidLEFT OUTER JOIN b c ON a.creator_id = b.uid--I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
portrman
Starting Member
24 Posts |
Posted - 2003-08-01 : 12:49:35
|
| ah perfect, I forgot you could using aliasing in join statments.Thanks a million. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-08-01 : 12:54:21
|
| You can use aliasing wherever you want and not just in join statements. You can alias tables, views, columns, etc...SELECT Column1 AS Alias1, Column2 AS Alias2FROM Table1 aTara |
 |
|
|
|
|
|
|
|