What is SQL Joins?
An SQL JOIN clause combines results from two or more tables. It creates a set of rows in a temporary table. SQL Joins is used for combining column from two or more tables by using values common in both tables. Join Keyword is used for joining of tables.
Types of Join
- Inner join
- Outer join
- Left join
- Right join
- Cross join or Cartesian Product
SQL Joins: Equi Join and Non Equi Join & Self Join
SQL Equi Join
The SQL Equi Join is a simple SQL join uses the equal sign(=) as the comparison operator for the condition. It has two types – SQL Outer join and SQL Inner join.
- Inner Join : In this type of join returns all rows from tables where the key record of one table is equal to the key records of another table.
- Outer Join : In this type of join returns all rows from one table and only those rows from the secondary table where the joined condition is satisfying i.e. the columns are equal in both tables.
SQL Non Equi Join
The SQL Non Equi Join is a join uses comparison operator other than the equal sign like >, <, >=, <= with the condition.
SQL Self Join
A Self Join is a type of sql join which is used to join a table to itself, particularly when the table has a FOREIGN KEY that references its own PRIMARY KEY. It is necessary to ensure that the join statement defines an alias for both copies of the table to avoid column ambiguity.
SQL Syntax for Joins
SELECT col1, col2, col3...
Where table1, table2 are tables that participating in joining, join_type is type of the join i.e. inner, outer, cross etc. and join_condition is condition for join & it is optional.
For More SQL Where Clause