0% found this document useful (0 votes)
7 views2 pages

SQL Join Theory Syntax

The document explains various types of SQL JOIN operations used to combine rows from multiple tables based on related columns. It details the syntax and return values for INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN (not directly supported in MySQL). Each JOIN type has specific use cases for retrieving matching or all records from the involved tables.

Uploaded by

rockyash155
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

SQL Join Theory Syntax

The document explains various types of SQL JOIN operations used to combine rows from multiple tables based on related columns. It details the syntax and return values for INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN (not directly supported in MySQL). Each JOIN type has specific use cases for retrieving matching or all records from the involved tables.

Uploaded by

rockyash155
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

7.

Perform JOIN Operations (All Types of Joins)

Theory:
JOINs in SQL are used to combine rows from two or more tables based on a related column
between them.

1. INNER JOIN

Syntax:

SELECT table1.column1, table2.column2


FROM table1
INNER JOIN table2 ON table1.common_column = table2.common_column;

Returns: Only the matching rows from both tables.

2. LEFT JOIN (LEFT OUTER JOIN)

Syntax:

SELECT table1.column1, table2.column2


FROM table1
LEFT JOIN table2 ON table1.common_column = table2.common_column;

Returns: All rows from the left table, and matched rows from the right table. NULL for
unmatched rows.

3. RIGHT JOIN (RIGHT OUTER JOIN)

Syntax:

SELECT table1.column1, table2.column2


FROM table1
RIGHT JOIN table2 ON table1.common_column = table2.common_column;

Returns: All rows from the right table, and matched rows from the left table. NULL for
unmatched rows.
4. FULL OUTER JOIN
Note: Not supported directly in MySQL

Syntax (Using UNION):

SELECT table1.column1, table2.column2


FROM table1
LEFT JOIN table2 ON table1.common_column = table2.common_column

UNION

SELECT table1.column1, table2.column2


FROM table1
RIGHT JOIN table2 ON table1.common_column = table2.common_column;

Returns: All records when there is a match in either table.

You might also like