2017-05-03 63 views
0

由於我無法找到正確的方式對其進行處理,因此我正在尋找解決此問題的最困難時間。從一個表格爲另一個表格中的每個結果返回系列

說我有一個表tbl_Users與主管的名字:

Employee  | Type 
------------ | ---------- 
Supervisor 1 | Specialist 
Supervisor 2 | Analyst 
Supervisor 3 | Specialist 
Supervisor 4 | Specialist 

而另一臺tbl_Auditable與員工姓名:

Employee 
---------- 
Employee 1 
Employee 2 
Employee 3 

兩者是獨一無二 - 在tbl_Users的名字將不會在存在tbl_Auditable表。我該如何去創建一個清單,以便tbl_Users中的每一行重複tbl_Auditable中的每個員工?

Specialist | Employee 
------------ | ---------- 
Supervisor 1 | Employee 1 
Supervisor 1 | Employee 2 
Supervisor 1 | Employee 3 
Supervisor 3 | Employee 1 
Supervisor 3 | Employee 2 
Supervisor 3 | Employee 3 
Supervisor 4 | Employee 1 
Supervisor 4 | Employee 2 
Supervisor 4 | Employee 3 

回答

1

你想要一個「交叉連接」。這可以這樣完成:

select t1.Employee as Specialist, t2.Employee 
from tbl_users as t1, tbl_Auditable t2 
where t1.type = 'Specialist' 
order by t1.Employee, t2.Employee 
+0

非常感謝!此解決方案在MS Access中工作。這正是我所期待的。 – Rawrcasm

相關問題