Joins
Joins: free step-by-step lesson with examples, common mistakes, and interview tips — part of Oracle SQL Tutorial on Toolliyo Academy.
On this page
Oracle SQL Tutorial · Lesson 56 of 96
Joins
Setup & Connect ✓ → Architecture & SQL ✓ → DBA & Tuning → Projects
DBA & Tuning · 3 — Production · ~10 min · Oracle — SQL & PL/SQL
What is this?
Joins combine rows from two or more tables using a matching key. INNER JOIN keeps matches only; LEFT JOIN keeps all rows from the left table.
Why should you care?
Orders without customers, or employees without departments, are useless reports — joins are how OracleCore builds real screens.
See it live — copy this example
Run these statements in SQL Developer or SQL*Plus against your lab PDB. Prefer a practice user — not SYS — for application SQL.
CREATE TABLE departments (
dept_id NUMBER PRIMARY KEY,
dept_name VARCHAR2(50)
);
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY,
emp_name VARCHAR2(100),
dept_id NUMBER REFERENCES departments(dept_id),
salary NUMBER(10,2)
);
INSERT INTO departments VALUES (10, 'Retail Banking');
INSERT INTO departments VALUES (20, 'IT');
INSERT INTO employees VALUES (101, 'Neha', 10, 55000);
INSERT INTO employees VALUES (102, 'Arjun', 20, 72000);
COMMIT;
SELECT e.emp_name, d.dept_name, e.salary
FROM employees e
INNER JOIN departments d ON e.dept_id = d.dept_id
ORDER BY e.salary DESC;
What happened?
- employees.dept_id points to departments.dept_id.
- INNER JOIN returns only employees who have a matching department.
Practice next
- Create both tables and insert sample rows.
- Run the INNER JOIN.
- Change to LEFT JOIN and insert an employee with NULL dept_id to see the difference.
- Add a third department with no employees.
- Select dept_name and COUNT(*) with GROUP BY.
Remember
JOIN links tables on keys. INNER = matches only; LEFT = keep left rows. Always alias tables (e, d) for clarity.
HR roster
HR needs employee name with department for payroll export.
Outcome: One join query replaces two manual spreadsheets.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!