我确信这里有一个答案,我只是很难解释我究竟想要的是什么让我很难研究:
我基本上有两张桌子:
表A:
PrimaryKeyID
SalesmanID
ManagerID
表B:
List of all employers with ID being the primary key (auto incremented from 1)
我需要从表A中的特定行获取表B中的Salesman和Manager Name。将表A视为事务日志。
答案 0 :(得分:1)
只是一种方法
SELECT A.ID, SalesMan.NAME, Manager.NAME
FROM TableA A
LEFT JOIN TableB SalesMan ON SalesMan.Id= A.SalesmanID
LEFT JOIN TableB Manager ON Manager.Id= A.ManagerID
WHERE (A.Your condition here)
AND (SalesMan.SalesmanID IS NOT NULL OR Manager.ManagerID IS NOT NULL)