Introduction to Joins In SQL

Whenever we want to fetch data from two or more database tables based on common field (column) we use Joins. 

Definition:
Technically Joins are SQL operations which help us in retrieving data from two or more tables that share a common field.

Types of Joins

There several Types of Joins such as:

  • Inner Join
  • Outer Join
  • Cross Join
  • Self-Join

Outer Join can further be divided into 3 more categories:

  • Right Outer Join
  • Left Outer Join
  • Full Outer Join

Joins in SQL by manish sharma

Apart from types of joins we also have two join conditions. These are:

  • Equi Joins
  • Non-Equi Joins

Equi Joins: This type of Join looks for common records in two tables on the basis of equality condition and then combines them. Equi-Join is constructed with the help of equality operator (=) where the values of Primary key and Foreign key are compared. Hence the common or matching records from the two tables are presented in the result.

Non Equi Joins: Here the equality operator is not used. Instead operators such as <, >, BETWEEN etc. are employed. Therefore Non Equi-Join is the opposite of Equi-Join and uses joining conditions excluding equal operator. For example, in a non Equi-Join condition you can use !=, <=,>=,<,> or BETWEEN etc. operators can be used for joining. For implementation you can read about Inner-Join.

Outer Join: Outer joins are the SQL operations which definitely return all the rows from Source table no matter whether there is a matching join condition hit or not. At the same time it returns only those rows of the target table that fulfills the matching join condition otherwise it just shows ‘null’ in the rows.

That’s all about Joins in SQL. Hope it gave you a rough idea of this topic and what is to come. Also I wish you enjoyed reading. Thanks & have a great day!