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 |
|
andyfraser
Starting Member
2 Posts |
Posted - 2006-10-15 : 11:39:57
|
Hi,Sorry if this has been asked before, I looked through the FAQ but could not find an answer to the following.I have a Project table which contains amongst other fields, a CreatedByID field and a LastModifiedByID field. Both these fields point to a User table. What I would like to do is get the two usernames from a query on the project table.I know how to get one usename using the following Sql command but how do I get access to the second username ?SELECT Project.Name,User.Username FROM Project,User WHERE Project.ID=@id AND User.ID = Project.CreatedByID;I hope my ramblings make sense AndyAndy |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-10-15 : 11:44:34
|
| SELECT Project.Name, A.Username As CreatedBy, B.Username As LastModifiedByFROM Project INNER JOIN User A ON A.ID = Project.CreatedByIDINNER JOIN User B ON B.ID = Project.LastModifiedByIDWHERE Project.ID=@id |
 |
|
|
andyfraser
Starting Member
2 Posts |
Posted - 2006-10-15 : 11:57:46
|
robvolk, you are a star , that worked perfectly - many thanks.Andy |
 |
|
|
|
|
|