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 |
jwells
Starting Member
17 Posts |
Posted - 2013-10-15 : 12:12:24
|
I have two tables, one is called InvTransfer and the WhsLoc. In InvTransfer I have two fields the hold the id to records WhsLoc. Tables look like:InvTransfer:IDCreatedOriginIDwhsFromIDwhsToIDCompletedEnabledWhsLoc:IDDisplayNameDescriptionTypeEnabledwhsFrom and whsTo are joined to WhsLoc by it's ID.I want to return * from InvTransfer but use the Name from WhsLoc table for each of whsFrom and whsTo. I know I can't simply join both fields to the WhsLoc table by he ID. How do I do this? |
|
jwells
Starting Member
17 Posts |
Posted - 2013-10-15 : 12:30:11
|
I was able to resolve it - thxSELECT dbo.Employees.EmployeeID, dbo.Employees.EmplName, dbo.InvTransfer.ID, dbo.InvTransfer.Created, dbo.InvTransfer.OriginID, dbo.InvTransfer.Completed, dbo.InvTransfer.Enabled, dbo.WhsLoc.Name AS FromName, WhsLoc_1.NameFROM dbo.InvTransfer INNER JOIN dbo.Employees ON dbo.InvTransfer.OriginID = dbo.Employees.ID INNER JOIN dbo.WhsLoc ON dbo.InvTransfer.whsFrom = dbo.WhsLoc.ID INNER JOIN dbo.WhsLoc WhsLoc_1 ON dbo.InvTransfer.whsTo = WhsLoc_1.ID |
 |
|
|
|
|