Joins in SQL

Rumman Ansari   Software Engineer   2023-03-25   6303 Share
☰ Table of Contents

Table of Content:


The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

it is important that the join is performed in the WHERE clause. Several operators can be used to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal to symbol.

Joins in SQL

There are different types of joins available in SQL ?

  • INNER JOIN: returns rows when there is a match in both tables.

  • LEFT JOIN: returns all rows from the left table, even if there are no matches in the right table.

  • RIGHT JOIN: returns all rows from the right table, even if there are no matches in the left table.

  • FULL JOIN: returns rows when there is a match in one of the tables.

  • 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.

  • CARTESIAN JOIN: returns the Cartesian product of the sets of records from the two or more joined tables.

Also we will learn about:

  • Retrieve only the non matching rows from the left table
  • Retrieve only the non matching rows from the right table
  • Retrieve only the non matching rows from both the left and right table

Let us now discuss each of these joins in detail.