TYPES of JOIN in SQL

WHAT ARE THE TYPES OF JOINS IN SQL?

JOIN clause combine rows from two or more tables, based on a common field between them.

There are five types of JOIN, defined by ANSI standard SQLโ€“

Sr.JOIN TYPESUSAGE
1INNER JOINReturns records that have matching values in both tables
2LEFT OUTER JOINReturns all records from left table and matching records from right table
3RIGHT OUTER JOINReturns all records from right table, and matching records from the left table
4FULL OUTER JOINReturns all records when there is a match in either left or right table
5CROSS JOINReturns combinations of each row of the first table with the each row from second table.

TYPE OF JOINS IN SQL

Syntax for INNER JOIN,LEFT JOIN,RIGHT JOIN,FULL OUTER JOIN-

SELECT <column_name(s)>

FROM <table1>

[INNER JOIN|LEFT JOIN|RIGHT JOIN|FULL OUTER JOIN]<table2>

ON <table1.column_name=table2.column_name>

WHERE<condition>;

Syntax for CROSS JOIN-

SELECT <column_name(s)>

FROM <table1>

CROSS JOIN<table2>;


Posted

in

Tags:

Comments

Leave a Reply