Types of Joins in SQL
Using the SELECT command, you can retrieve data from several related tables also. But this is possible only if the tables are related to one other. The join operation is used to combine columns from multiple tables. In a join, the tables to be included in the query are specified in the FROM clause, separated by commas.
Types of Joins:
There are four types join in SQL:
i. EQUI JOIN: When two tables are joined together using equality of values in one or more columns, they would make an Equi Join. It has the following syntax:
SELECT <column-name(s)> FROM <table1>, <table2>, ..., <tableN> WHERE <table1.col1>= <table2.col1> AND <table3.col2>=<table2.col4> AND ... AND <table2.col3>=<tableN.colN>;
ii. OUTER JOIN:In an OUTER JOIN if there are any values in one table that do not have corresponding values in the other table, they will not be selected.
iii. NON-EQUI JOIN: A NON-EQUI JOIN is a query that specifies some relationship between tables other than equality.
iv. SELF JOIN: SELF JOIN is the joining of a table to itself. In this join, each row of the table is combined with itself and every other row of the table. This can be viewed as a joining of two copies of the same table.