我有一个任务表,例如:
TaskTitle DueDate Person Manager
Report 3/28/15 John Dave
Inspection 4/10/15 Brian Shane
和联系人表格:
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
我想要做的是写一个这样的查询:
PEmail MEmail TaskTitle
john@company.com Dave@company.com Report
brian@company.com Shane@company.com Inspection
我可以通过查询来选择PEmail或MEmail,但不能同时选择它们吗?
SELECT [Contacts].[Email], [Tasks].[TaskTitle]
FROM tasks
LEFT JOIN [Contacts]
ON [Tasks].[Person] = [Contacts].[Contact]
和
SELECT [Contacts].[Email], [Tasks].[TaskTitle]
FROM tasks
LEFT JOIN [Contacts]
ON [tasks].[Manager] = [Contacts].[Contact]
这是否有特定的事情被称为?多重连接或多重选择?我一直坚持这个。
答案 0 :(得分: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]