Equi Join - (Oracle Joins)
In Oracle database, an equi join is a type of join that is used to combine data from two tables where the data in one or more columns matches. The matching columns are called the join columns.
Syntax
The syntax for performing an equi join using the JOIN
keyword in Oracle is as follows:
SELECT column1, column2, ...
FROM table1 JOIN table2
ON table1.column = table2.column;
Here, column1
, column2
, ... are the columns you want to select from the tables, table1
and table2
are the tables you want to join, and column
is the column that will be used for the join.
Example
Here is an example of performing an equi join in Oracle:
SELECT employees.first_name, employees.last_name, departments.department_name
FROM employees
JOIN departments
ON employees.department_id = departments.department_id;
Output
FIRST_NAME LAST_NA DEPARTMENT_NAME
----------- ------- ------------------------------
Steven King Executive
Neena Kochhar Executive
Lex De Haan Executive
Alexander Hunold IT
Bruce Ernst IT
David Austin IT
Valli Pataballa IT
Diana Lorentz IT
Nancy Greenberg Finance
Daniel Faviet Finance
Explanation
In the above example, we have joined the employees
and departments
tables using the department_id
column as the join column. We have selected the first_name
and last_name
columns from the employees
table and the department_name
column from the departments
table.
Use
Equi joins are useful for combining data from two or more tables where the data in one or more columns matches. They are used to retrieve data that is spread across multiple tables in a database.
Important Points
- Equi join is a join in which the matching columns have the same name and data type in both tables.
- The
JOIN
keyword is used to perform an equi join in Oracle. - The join column is specified using the
ON
keyword.
Summary
In summary, equi join is a type of join used in Oracle to combine data from two tables where the matching columns have the same name and data type. They are useful for combining data from multiple tables in a database.