JOINS are used to combine data across tables by matching rows. There are 5 types of joins: equi, non-equi, outer, self, and inner. Outer joins return all rows from the first table and matched rows from the second table, returning null values for non-matches. The 3 types of outer joins are left (returns all rows from left table), right (returns all rows from right table), and full (returns all rows from both tables).
2. What are JOINS?
JOINS are used to combine the data across table.
It is performed by WHERE clause which combine the
specified rows of table.
A query can contain zero, one, or multiple JOIN
operations.
3. Types of JOINS
There are 5 types of JOINS :-
1. Equi – Join
2. Non Equi – Join
3. Outer Join
4. Self Join
5. Inner Join
4. Outer Join
The outer join operator is a plus character in
parentheses (+).
The outer join operator (+) is on the column that
contains the null value.
An outer join retrieves a row even when one of the
columns in the join contains a null value.
You perform an outer join by supplying the outer join
operator in the join condition.
6. Example of Outer Join
Example : -
SELECT e.ename, j.jobtitle FROM employee e, job j
WHERE e.empno = j.empno (+);
7. Types of Outer Join
Left Outer Join
Right Outer Join
Full Outer Join
8. Left Outer Join
The left outer join returns a result table with
the matched data of two tables then remaining rows
of the lefttable and null for the right table's column.
Syntax :-
select column-name-list from table-name1, table-
name2 on table-name1.column-name = table-
name2.column-name(+);
Ex :- SELECT * FROM class LEFT OUTER JOIN
class_info ON (class.id=class_info.id);
9. Right Outer Join
The right outer join returns a result table with
the matched data of two tables then remaining rows
of the right table and null for the left table's columns.
Syntax :- select column-name-list from table-name1,
table-name2 on table-name1.column-name(+) = table-
name2.column-name;
Ex :- SELECT * FROM class RIGHT OUTER JOIN
class_info on (class.id=class_info.id);
10. Full Outer Join
The full outer join returns a result table with
the matched data of two table then remaining rows
of both lefttable and then the right table.
Syntax :- select column-name-list from table-name1
FULL OUTER JOIN table-name2 on table-
name1.column-name = table-name2.column-name;
Ex :- SELECT * FROM class FULL OUTER JOIN
class_info on (class.id=class_info.id);