1

I have a Tasks table for example:

TaskTitle DueDate Person Manager
Report     3/28/15  John   Dave
Inspection 4/10/15  Brian  Shane

and a Contacts Table:

ID   Contact  Email                Manager
1    John     john@company.com     False
2    Dave     dave@company.com     True
3    Brian    brian@company.com    False
4    Shane    shane@company.com    True

And what I want to do is write a query like this:

PEmail            MEmail             TaskTitle 
john@company.com  Dave@company.com   Report
brian@company.com Shane@company.com  Inspection

I can can get the query to select the PEmail or the MEmail, but not both together?

SELECT [Contacts].[Email], [Tasks].[TaskTitle]
FROM tasks
LEFT JOIN [Contacts] 
ON [Tasks].[Person] = [Contacts].[Contact]

and

SELECT [Contacts].[Email], [Tasks].[TaskTitle]
FROM tasks
LEFT JOIN [Contacts] 
ON [tasks].[Manager] = [Contacts].[Contact]

Is there a specific thing this is called? A multiple join or multiple select? I've been really stuck on this.

arsarc
  • 443
  • 1
  • 9
  • 22
  • You can make joins over more than two tables in a query. You actually can join a single table more than once. – arkascha Mar 19 '15 at 19:39

1 Answers1

0
SELECT [ManagerContacts].[Email] MEmail, 
       [PersonContacts].[Email] PEmail, 
       [Tasks].[TaskTitle]
FROM tasks
    LEFT JOIN [Contacts] ManagerContacts
ON [tasks].[Manager] = [ManagerContacts].[Contact]
    LEFT JOIN [Contacts] PersonContacts
ON [tasks].[Person] = [PersonContacts].[Contact]
stuartd
  • 70,509
  • 14
  • 132
  • 163