Tuesday, 17 March 2015

Introduction of Joins In SQL

Introduction of Joins In SQL.

Joins In SQL
Whenever we want to fetch data from two or more database tables based on common field (column) we use Joins. 
DEF:
  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
  1. Inner Join
  2. Outer Join
  3. Cross Join
  4. Self-Join
Outer Join can further be categorize into 3 more categories

  1. Right Outer Join
  2. Left Outer Join
  3. Full Outer Join.
sql joins rebellionrider
Apart from types of join we also have two join conditions these are

  1. Equi Joins
  2. Non-Equi Joins

Equi Join: 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 Join: Here 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 see Inner-Join.

Outer Join: Outer joins are the SQL operation 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 fulfils the matching join condition otherwise just shows ‘null’ in the rows

No comments:

Post a Comment