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.
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
- Right Outer Join
- Left Outer Join
- Full Outer Join.
Apart from types of join we also have two join conditions these are
- Equi Joins
- 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