![SQL Joins – SQL Joins and Types of Joins issues-after-qlikview-version-upgrade-on-passive-node-of-production-servers](https://www.s-squaresystems.com/wp-content/uploads/SQL-Joins-–-SQL-Joins-and-Types-of-Joins.png)
JOINS: Join is used to combine one or more tables, from tables based on condition (Common fields). Joins are divided into four categories.
-
- Inner Join
- Left Outer Join
- Right Outer Join
- Full Outer Join
Table A and Table B, with some sort of relation specified by primary and foreign keys. The result of joining these tables together can be visually represented by the following diagram:
![Picture84](https://www.s-squaresystems.com/wp-content/uploads/Picture84.png)
Below are the tables Table A and Table B
![Picture85](https://www.s-squaresystems.com/wp-content/uploads/Picture85.png)
![Picture86](https://www.s-squaresystems.com/wp-content/uploads/Picture86.png)
Types of joins:
INNER JOIN: Returns records that have matching values in both tables.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,….
FROM table1
INNER JOIN table2
ON table1.matching_column = table2.matching_column;
E.g.:
Table 1: Table A
Table 2: Table B
matching_column: Column common to both the tables.
![Picture87](https://www.s-squaresystems.com/wp-content/uploads/Picture87.png)
E.g.:
![Picture88](https://www.s-squaresystems.com/wp-content/uploads/Picture88.png)
LEFT JOIN: Returns all records from the left table, and the matched records from the right table. LEFT JOIN is also known as LEFT OUTER JOIN.
Syntax:
SELECT table1.column1, table1.column2, table2.column1,….
FROM table1
LEFT OUTER JOIN table2
ON table1.matching_column = table2.matching_column;
![Picture89](https://www.s-squaresystems.com/wp-content/uploads/Picture89.png)
E.g.:
![Picture92](https://www.s-squaresystems.com/wp-content/uploads/Picture92.png)
RIGHT JOIN: Returns all records from the right table, and the matched records from the left table. RIGHT JOIN is also known as RIGHT OUTER JOIN.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,….
FROM table1
RIGHT OUTER JOIN table2
ON table1.matching_column = table2.matching_column;
![Picture93](https://www.s-squaresystems.com/wp-content/uploads/Picture93.png)
E.g.:
![Picture94](https://www.s-squaresystems.com/wp-content/uploads/Picture94.png)
FULL JOIN: Returns all records when there is a match in either left or right table. The rows for which there is no matching, the result-set will contain NULL values.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,….
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
![Picture95](https://www.s-squaresystems.com/wp-content/uploads/Picture95.png)
E.g.:
![Picture96](https://www.s-squaresystems.com/wp-content/uploads/Picture96.png)