T-SQL Tutorial

SQL Full Join


Full Join Example:

SELECT * FROM employee e FULL JOIN department d
ON e.DEP_ID = d.DEP_ID
ORDER BY e.employee_id ;

Employee table:

EMPLOYEE_IDNAMEDEP_ID
1EMPLOYEE_121
2EMPLOYEE_222
3EMPLOYEE_323
4EMPLOYEE_424
5EMPLOYEE_5

Department table:

DEP_IDDEP_NAME
21DEP_21
22DEP_22
23DEP_23
24DEP_24
25DEP_25

Full Join Result:

EMPLOYEE_IDNAMEDEP_IDDEP_IDDEP_NAME
1EMPLOYEE_12121DEP_21
2EMPLOYEE_22222DEP_22
3EMPLOYEE_32323DEP_23
4EMPLOYEE_42424DEP_24
5EMPLOYEE_5
25DEP_25