In SQL, a join is used to compare and combine — literally join — and
return specific rows of data from two or more tables in a database.
An inner join finds and returns matching data from tables,
while an outer join finds and returns matching data and some dissimilar
data from tables
INNER JOIN :
The inner join will keep only the information from the two joined tables
that is related.
OUTER JOIN:
There are three types of outer joins:
Left Outer Join (or Left Join)
Right Outer Join (or Right Join)
Full Outer Join (or Full Join)
INNER JOIN:
is used when retrieving data from multiple
tables and will return only matching data.
LEFT OUTER JOIN:
is used when retrieving data from
multiple tables and will return
left table and any matching right table records.
RIGHT OUTER JOIN:
is used when retrieving data from
multiple tables and will return right
table and any matching left table records
FULL OUTER JOIN:
is used when retrieving data from
multiple tables and will return both
table records, matching and non-matching.
-- Rows with ID existing in both a and b
-- JOIN is equivalent to INNER JOIN
SELECT a.ID, a.NAME, b.VALUE1 FROM table1 a
JOIN table2 b ON a.ID = b.ID
WHERE a.ID >= 1000;
-- ⇓ Test it ⇓ (Fiddle source link)
There really is no difference between a LEFT JOIN and a LEFT OUTER JOIN.
Both versions of the syntax will produce the exact same result in PL/SQL.
Some people do recommend including outer in a LEFT JOIN clause so it's
clear that you're creating an outer join, but that's entirely optional
INNER JOIN:
is used when retrieving data from multiple
tables and will return only matching data.
FULL OUTER JOIN:
is used when retrieving data from
multiple tables and will return both
table records, matching and non-matching.
SELECT * FROM TableA AS a INNER JOIN TableB AS b USING (Column1);
SELECT * FROM TableA AS a INNER JOIN TableB AS b ON a.Column1 = b.Column1;