SQL JOINS
SQL JOINS are used to combine records from two or more tables in a database.
To apply a join in both tables, it is necessary to have at least one relative(common) column.
We can combine up to 32 tables in a single query.
Syntax:
SELECT table1.column1 , table2.column2 FROM table1.columnname JOIN table2.columnname ;
Let’s understand the JOINS with an example. For Demo, we will be using the Emp and Project Tables.
Table Emp
Table Project
To generate a result set through joins, we can utilize both the emp and project tables.
The relative column between the two tables is Ecode.
Types of Joins in SQL
Here is a list of SQL JOIN types.
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 the left or right table.