SQL Joins
has average rating
8
out of 10.
Total 54 users rated.
What is SQL Joins?
An SQL JOIN clause combines rows from two or more tables. It creates a set of rows in a temporary table.
How to Join two tables in SQL?
A JOIN works on two or more tables if they have at least one common field and have a relationship between them.
JOIN keeps the base tables (structure and data) unchanged.
SQL JOINS : EQUI JOIN and NON EQUI JOIN
The are two types of SQL JOINS - EQUI JOIN and NON EQUI JOIN
1) 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.
2) 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 EQUI JOIN : INNER JOIN and OUTER JOIN
The SQL EQUI JOIN can be classified into two types - INNER JOIN and OUTER JOIN
1. SQL INNER JOIN
This type of EQUI JOIN returns all rows from tables where the key record of one table is equal to the key records of another table.
2. SQL OUTER JOIN
This type of EQUI 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.
In order to perform a JOIN query, the required information we need are:
a) The name of the tables
b) Name of the columns of two or more tables, based on which a condition will perform.
Syntax
FROM table1 join_type table2 [ON (join_condition)]
Parameters
| Name | Description |
|---|---|
| table1, table2 | Tables participating in joining. |
| join_type | Type of the join. |
| join_condition | Some condition. This is optional. |
Pictorial Presentation of SQL Joins :

Example
Sample table : company
Sample table : foods
To join two tables 'company' and 'foods', the following sql statement can be used :
SELECT company.company_id,company.company_name, foods.item_id,foods.item_name FROM company,foods;
Output

Outputs of the said SQL statement shown here is taken by using Oracle Database 10g Express Edition.
Here is a new document which is a collection of questions with short and simple answers, useful for learning SQL as well as for interviews.

