我有一个交易表(名为G7),其字段为
1. ID
2. Module ID
3. Employer ID
4. Employee ID (From) - **refers to Employee ID Table** -
5. Employee ID (To) - **refers to Employee ID Table** -
6. Transaction Date
员工ID (名为I9 )表格中包含
字段1. Employee ID
2. Employee First Name
3. Employee Last Name
4. Employee Email Address
在输出SQL语句报告中,我需要有事务报告(基于(G7)
)1. Transaction Date
2. Employee First Name (From)
3. Employee Last Name (From)
4. Employee First Name (To)
5. Employee Last Name (To)
令人讨厌的是,我仍然无法使SQL语句生效。有人可以帮帮我吗?
答案 0 :(得分:0)
这应该这样做:
SELECT Transaction.TransactionDate,
A.FirstName,
A.LastName,
B.FirstName,
B.LastName
FROM Transaction
JOIN Employee AS A ON Transaction.From = A.EmployeeID
JOIN Employee AS B ON Transaction.To = B.EmployeeID
如果您尝试获取具有相同表的不同含义的数据,请确保通过使用“AS”定义别名来创建它们之间的差异。此外,您必须以正确的方式定义连接。我想找到两者的组合是你的问题。