You are on page 1of 11

SQL JOIN

Presented By : ANJAN BANERJEE

Employee Id : 1768455
Index :
◦ A Brief Introduction about SQL
◦ SQL Joins
◦ Simple or Inner Join
◦ Outer Join :
1) Left Outer Join
2) Right Outer Join
3) Full Outer Join
◦ Self Join
◦ Cross Join
A Brief Introduction About SQL
➢ SQL stands for Structured Query Language.
➢ It is designed for managing data in a Relational Database Management System (RDMS).
➢ SQL can execute queries against a database
➢ SQL can retrieve data from a database
➢ SQL can insert records in a database
➢ SQL can update records in a database
➢ SQL can delete records from a database
➢ SQL can create new databases
➢ SQL can create new tables in a database
➢ SQL can create stored procedures in a database
➢ SQL can create views in a database
➢ SQL can set permissions on tables, procedures, and views
SQL Joins
◦ As the name shows, JOIN means to combine something. In case of SQL, JOIN means "to combine two or more
tables".
◦ SQL JOINS are used to retrieve data from multiple tables. A SQL JOIN is performed whenever two or more tables are
listed in a SQL statement.
◦ The SQL JOIN clause takes records from two or more tables in a database and combines it together.
◦ Different types of SQL Joins:

Simple join or Inner Join


Left outer join
Outer Join
Right outer join

Self Join Full outer join

Cross or Cartesian Join


Simple or Inner Join
◦ It is the most common I Simple Join produces the result :
type of SQL join. N
◦ The INNER JOIN keyword
P
selects all rows from both U
the tables as long as T
condition satisfies. This key
word will create the result-
O
set by combining all rows U
from both the tables where T
the condition satisfies i.e. P
value of the common field U
will be same.
T
◦ SQL INNER JOINS return all
rows from multiple tables
where the join condition is
met.
Left Outer Join
I Left Outer Join produce the result
◦ The SQL LEFT JOIN returns all rows N
from the left table, even if there P
are no matches in the right table. U
This means that if the ON clause T
matches 0 (zero) records in the
right table; the join will still return O
a row in the result, but with NULL U
in each column from the right table. T
P
◦ This means that a left join returns all U
the values from the left table, plus T
matched values from the right table
or NULL in case of no
matching join predicate.
RIGHT OUTER JOIN
I Right outer join produce the result :
◦ The SQL RIGHT JOIN returns all N
rows from the right table, even P
if there are no matches in the U
left table. This means that if the
T
ON clause matches 0 (zero)
records in the left table; the join O
will still return a row in the result, U
but with NULL in each column T
from the left table.
P
◦ This means that a right join returns U
all the values from the right table, T
plus matched values from the left
table or NULL in case of no
matching join predicate.
Full Join
I
◦ The SQL FULL JOIN combines the
N
results of both left and right outer
joins.
P Full Join produces the result
U
O
T
U
◦ The joined table will contain all T
records from both the tables
P
and fill in NULLs for missing matches
on either side.
U
T
SELF JOIN
◦ The SQL SELF JOIN is used to join a table to itself as if the table were two tables;
temporarily renaming at least one table in the SQL statement.

INPUT OUTPUT
Cross Join
◦ The CARTESIAN JOIN or CROSS JOIN returns the Cartesian product of the
sets of records from two or more joined tables. Thus, it equates to an inner
join where the join-condition always evaluates to either True or where the
join-condition is absent from the statement.

INPUT OUTPUT

You might also like