0 votes
in Sql by
What is a Join? List its different types.

1 Answer

0 votes
by
The SQL Join clause is used to combine records (rows) from two or more tables in a SQL database based on a related column between the two.

There are four different types of JOINs in SQL:

(INNER) JOIN: Retrieves records that have matching values in both tables involved in the join. This is the widely used join for queries.

SELECT *

FROM Table_A

JOIN Table_B;

SELECT *

FROM Table_A

INNER JOIN Table_B;

LEFT (OUTER) JOIN: Retrieves all the records/rows from the left and the matched records/rows from the right table.

SELECT *

FROM Table_A A

LEFT JOIN Table_B B

ON A.col = B.col;

RIGHT (OUTER) JOIN: Retrieves all the records/rows from the right and the matched records/rows from the left table.

SELECT *

FROM Table_A A

RIGHT JOIN Table_B B

ON A.col = B.col;

FULL (OUTER) JOIN: Retrieves all the records where there is a match in either the left or right table.

SELECT *

FROM Table_A A

FULL JOIN Table_B B

ON A.col = B.col;

Related questions

0 votes
asked Dec 14, 2020 in Sql by SakshiSharma
+2 votes
0 votes
asked Dec 13, 2020 in Sql by SakshiSharma
...