Join
Join
Join
SQL Joins
Join
• An SQL JOIN clause is used to combine rows
from two or more tables, based on a common
field between them.
Obtaining Data from Multiple Tables
DEPARTMENTS
• EMPLOYEES
Syntax
• Use a join to query data from more than one
table.
SELECT table1.column, table2.column
FROM table1, table2
WHERE table1.column1 = table2.column2
• Write the join condition in the WHERE clause.
• Prefix the column name with the table name
when the same column name appears in more
than one table.
Types of join
• Equijoin
• Non-equijoin
• Outer join
• Self join
Equijoin
• SQL EQUI JOIN performs a JOIN against
equality or matching column(s) values of the
associated tables. An equal sign (=) is used as
comparison operator in the where clause to
refer equality.
• EQUI JOIN may also be performed by using
JOIN keyword followed by ON keyword and
then specifying names of the columns along
with their associated tables to check equality.
Example
EMPLOYEE DEPARTMENT
DEPARTMENT EMPLOYEE