I'm trying to get and join information from a SQL Server from two tables.
Let's say I have these two tables:
Table Resources
:
ID Resource
---------------
1 Alex
2 Dennis
3 Diane
Table Projects
:
Project Manager Leader Engineer
------------------------------------------
pro_18001 1 2 3
I want to get the following result:
Project Manager Leader Engineer
---------------------------------------------
pro_18001 Alex Dennis Diane
I suppose the SQL query should look something like:
SELECT
[Projects].[Project]
[Resources].[Resource]
[Resources].[Resource]
[Resources].[Resource]
FROM
[Projects]
LEFT JOIN
[Resources] ON
[Projects].[Manager] = [Resources].[ID] AND
[Projects].[Leader] = [Resources].[ID] AND
[Projects].[Engineer] = [Resources].[ID]
WHERE
[Project].[Projects] = 'pro_18001'
But I'm sure the below part is not right as there is 3 times the same column and the join might not pick the right ones in the right order...
SELECT
[Projects].[Project]
[Resources].[Resource]
[Resources].[Resource]
[Resources].[Resource]
So how to join the same column multiple times in the right place?