gpt4 book ai didi

mysql - 在查询中查询? (微软 Access )

转载 作者:行者123 更新时间:2023-11-30 22:47:35 29 4
gpt4 key购买 nike

例如,我有一个任务表:

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]

这个东西有具体的名称吗?多重连接或多重选择?我一直坚持这一点。

最佳答案

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]

关于mysql - 在查询中查询? (微软 Access ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29153381/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com