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 |
|
castroc
Starting Member
2 Posts |
Posted - 2008-05-09 : 21:00:21
|
| Hello All,I have a little problem. Here is the scenario:I got two tables Asset and PersonnelPersonnel has FirstName, LastName,and username which is unique.Asset table stores all information related to an asset and the username to whom the asset is assigned and the POC username. The tables look like this:Personnel TableFirstName, Last Name, UserNameJohn, Doe, jdoeBill, Smith, bsmithAsset TablePOCUserName, AssigneeUserNamejdoe,bsmithMy problem arises when I want to display First Name and Last Name for both the POCusername and the AssigneeUserName since FirstName and LastName columns exists once in the Personnel table. How can I display the columns twice. Lets say POCFirstName, POCLastName, AssigneeFirstName, and AssigneeLastName. Or this is something that can't be done.The query below only display the Assignee info. Of course, I need to something else to display the POC info as well...don't where to go from here...select tblPersonnel.FirstName, tblPersonnel.LastName, tblAsset.AssigneeUserName, tblAsset.POCUserName from tblVendor, tblAsset, tblPersonnelwhere and tblPersonnel.UserName = tblAsset.AssigneeUserNameand tblAsset.POCUserName in(select tblPersonnel.UserName from tblAsset, tblPersonnel where tblPersonnel.UserName= tblAsset.POCUserName)Any help is greatly appreciated~N |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-05-09 : 22:01:33
|
| Try this:selectpr.FirstName,pr.LastName,a.POCUserName,t.FirsName,t.LastName,a.AssigneeUserNamefrom dbo.personnel prleft join dbo.Asset aon pr.Username = a.pocusername inner join dbo.personnel ton a.assigneeusername = t.Username |
 |
|
|
castroc
Starting Member
2 Posts |
Posted - 2008-05-10 : 12:39:25
|
| Thank you very much! this did the trick!I really appreciate your help!~N |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-05-10 : 14:23:53
|
| you are welcome. |
 |
|
|
|
|
|
|
|