假设我在 SQL Server 中有这些表:
tbl_申请人
ID | name | typeid | depid
---+------+--------+-------
1 | Mark | 1 | NULL
2 | Ted | 2 | 1
Run Code Online (Sandbox Code Playgroud)
tbl_ApplicantType
ID | Type
---+----------
1 | Student
2 | Employee
Run Code Online (Sandbox Code Playgroud)
tbl_部门
ID | department_name
---+----------------
1 | Finance
2 | HR
Run Code Online (Sandbox Code Playgroud)
我想加入表格以便我可以得到下面的结果
这是我想要的结果:
Name | type | department
-----+----------+---------------
Mark | Student | NULL
Ted | Employee | HR
Run Code Online (Sandbox Code Playgroud)
我有这个选择语句:
select
a.name, b.type, c.department_name
from
tbl_applicants a, tbl_ApplicantType b, tbl_Department c
where …Run Code Online (Sandbox Code Playgroud)