Using the JOIN keyword, we can specify “joined relations”. Two joined relations look like any other relation.

There are many different types of joins:
Join Condition (SQL)
We can retrieve the name and address of all employees who work for the ‘Research’ department by specifying a join condition:
SELECT FNAME, LNAME, ADDRESS FROM EMPLOYEE, DEPARTMENT WHERE DNAME = 'Research' AND DNUMBER = DNOWe can specify as many join conditions as we want.
We can also use an explicit
JOINclause: Link to originalSELECT location, mgrssn FROM DEPARTMENT JOIN DEPT_LOCATIONS ON DEPARTMENT.number=DEPT_LOCATIONS.number WHERE DNAME = 'Research';Natural Join (SQL)
Natural Join (
Link to originalNATURAL JOIN): (same asJOIN) no join condition may be specified, implicit condition to join on attributes with the same nameInner Join (SQL)
Inner Join (
Link to originalINNER JOIN): tuple is included in the result only if a matching tuple exists in the other relation (this is the default type ofJOIN)Outer Join (SQL)
Outer Join: all matching tuples are returned are returned (depending on type)
Left Outer Join (SQL)
Left Outer Join (
LEFT OUTER JOIN): Keeps values from the left table even if they are not matched.SELECT E.name, S.fname FROM ( EMPLOYEE E LEFT OUTER JOIN EMPLOYEE AS S ON E.super_ssn=S.ssn )This will match employees without supervisors.
Link to originalRight Outer Join (SQL)
Right Outer Join (
RIGHT OUTER JOIN): Keeps values from the right table even if they are not matched.SELECT E.name, S.fname FROM ( EMPLOYEE E RIGHT OUTER JOIN EMPLOYEE AS S ON E.super_ssn=S.ssn )This will match employees who are not supervising anyone.
Link to originalFull Outer Join (SQL)
Full Outer Join (
FULL OUTER JOIN): Keeps values from the both tables even if they are not matched.SELECT E.name, S.fname FROM ( EMPLOYEE E FULL OUTER JOIN EMPLOYEE AS S ON E.super_ssn=S.ssn )This will match employees without supervisors and employees not supervising anyone.
Link to original
Cross Join (SQL)
Cross Join (
CROSS JOIN): Returns the Cartesian Product of two or more tables. Link to originalSELECT E.name, S.name FROM ( EMPLOYEE E CROSS JOIN EMPLOYEE S )- Multi-way joins: we can chain multiple joins in one query for multiple tables.