The SQL FULL JOIN keyword returns rows when there is a match in either of the tables.
In this example, employeeID is a primary key in the table called "Employees". You'll notice that employeeID also exists in the "Departments" table, but as a foreign key.
Using an SQL Join, we can combine these two tables into one when presenting the results of a query.
In this example, using a RIGHT JOIN, we can build a query to display the departments and employees even though not every employee is assigned to a department, such as in the case of 'Fred White'.
The two tables are joined by the 'employeeID' field.
We can use the RIGHT JOIN to bind this data together.
SELECT tableName#.columnName#, tableName#.columnName#, etc...|
FULL JOIN tableName2
ON tableName1.columnName# = tableName2.columnName#
List the departments and their assigned employees.
SELECT Departments.deptName, Employees.employeeName |
FULL JOIN Employees
ON Departments.employeeID = Employees.employeeID
| ||Fred White|
You should immediately notice that 'Fred White' from the Employees table, and 'Operations' from the Departments table are
This is because we used a Full Join and any records matching in either table will be included in the results.
Recommended Books & Training Resources