📅  最后修改于: 2023-12-03 15:03:23.539000             🧑  作者: Mango
Equi Join is a type of join operation where two tables are joined based on one or more common columns. In Oracle, an equi join can be performed using the JOIN or INNER JOIN clause. In this article, we will explore how to use Equi Join in Oracle.
SELECT column_name(s)
FROM table_name1
JOIN table_name2
ON table_name1.column_name = table_name2.column_name;
Let's consider two tables - employees
and departments
.
employees:
| id | name | salary | department_id | |----|------|--------|---------------| | 1 | John | 50000 | 1 | | 2 | Jane | 60000 | 2 | | 3 | Jack | 55000 | 1 | | 4 | Jill | 65000 | 2 |
departments:
| id | name | |----|---------| | 1 | IT | | 2 | Finance |
We can join these two tables based on their department_id
columns as follows:
SELECT employees.name, departments.name
FROM employees
JOIN departments
ON employees.department_id = departments.id;
This will return:
| name | name | |------|---------| | John | IT | | Jane | Finance | | Jack | IT | | Jill | Finance |
Equi Join is a powerful SQL operation that allows us to combine data from two or more tables. In Oracle, it can be performed using the JOIN or INNER JOIN clause. By carefully specifying the common columns in our tables, we can easily join them and derive meaningful results.