SQL joins
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
Then look at a selection from the "employee" table:
Notice that the "Employee_id" column in the "products" table refers to the "Employee_id" in the "employee" table. The relationship between the two tables above is the "Employee_id" column.
Then, we can create the following SQL statement (that contains an INNER JOIN), that selects records that have matching values in both tables:
Different Types of SQL JOINs
- (INNER) JOIN : Returns records that have matching values in both tables
- LEFT (OUTER) JOIN : Returns all records from the left table, and the matched records from the right table
- RIGHT (OUTER) JOIN : Returns all records from the right table, and the matched records from the left table
- FULL (OUTER) JOIN : Returns all records when there is a match in either left or right table