Informatics Practices

SQL Equi Join | Working with Two Tables | Complete Notes | CBSE Class 12 Informatics Practices (2026–27)

Class 12 · Informatics Practices

SQL Equi Join (Working with Two Tables)

In a relational database, information is often stored in multiple related tables instead of one large table. To retrieve related information from two or more tables, SQL provides the concept of Joins.

According to the CBSE Class 12 Informatics Practices syllabus, students are required to learn the Equi Join, which joins two tables using matching values in common columns.


Why Do We Need Multiple Tables?

Storing all information in a single table creates data redundancy and makes database management difficult. Splitting data into related tables improves organization, reduces duplication, and increases efficiency.

Example:

  • The Student table stores student details.
  • The Course table stores course details.
  • A common column such as CourseID links both tables.

Primary Key and Foreign Key

Primary Key

A Primary Key uniquely identifies each record in a table.

Example: StudentID, CourseID


Foreign Key

A Foreign Key is a column in one table that refers to the Primary Key of another table.

It establishes a relationship between the tables.


Sample Tables

Student Table

StudentID Name CourseID
101 Amit C01
102 Neha C02
103 Rohan C01
104 Priya C03

Course Table

CourseID CourseName Fee
C01 Python 5000
C02 SQL 4500
C03 AI 6000

What is an Equi Join?

Definition

An Equi Join is a type of join in which records from two tables are combined using the equality (=) operator on matching columns.


Syntax of Equi Join

SELECT column_list
FROM Table1, Table2
WHERE Table1.CommonColumn =
      Table2.CommonColumn;

Example 1: Display Student Name and Course Name

SELECT Student.Name,
       Course.CourseName
FROM Student, Course
WHERE Student.CourseID =
      Course.CourseID;
Output
Name CourseName
Amit Python
Neha SQL
Rohan Python
Priya AI

Example 2: Display Student Name and Course Fee

SELECT Student.Name,
       Course.Fee
FROM Student, Course
WHERE Student.CourseID =
      Course.CourseID;

Example 3: Display All Student and Course Details

SELECT *
FROM Student, Course
WHERE Student.CourseID =
      Course.CourseID;

Using Table Aliases

Table aliases make SQL queries shorter and easier to read.

SELECT S.Name,
       C.CourseName
FROM Student S,
     Course C
WHERE S.CourseID =
      C.CourseID;

Another Example

Employee Table

EmpID Name DeptID
1 Amit D01
2 Neha D02
3 Rohan D01

Department Table

DeptID Department
D01 Sales
D02 Finance

Example Query

SELECT Employee.Name,
       Department.Department
FROM Employee,
     Department
WHERE Employee.DeptID =
      Department.DeptID;

How an Equi Join Works


Student Table
     │
     │ CourseID
     ▼
Course Table
     │
Matching Values
     ▼
Combined Result


Advantages of Equi Join

  • Combines related information from different tables.
  • Reduces duplicate data.
  • Maintains database normalization.
  • Produces meaningful reports.
  • Improves database organization.

Real-Life Applications

Field Example
School Students and Classes
Hospital Patients and Doctors
Bank Customers and Accounts
Library Books and Publishers
E-Commerce Products and Categories

Common Errors

Error Reason
Unknown Column Incorrect column name.
Ambiguous Column Same column name exists in both tables. Use table names or aliases.
Missing Join Condition Produces a Cartesian Product instead of an Equi Join.
Syntax Error Incorrect SQL syntax.

Quick Revision

Concept Remember
Primary Key Uniquely identifies each record.
Foreign Key Links two tables.
Equi Join Uses the = operator.
Table Alias Short name for a table.
Join Condition Written in the WHERE clause.

CBSE Exam Tips

  • Always identify the common column between the tables.
  • Use the equality operator (=) in an Equi Join.
  • Remember that the join condition is written in the WHERE clause in the CBSE syllabus style.
  • Use table aliases to make queries shorter and easier to understand.
  • Do not forget the join condition; otherwise, a Cartesian Product may be generated.

Summary

An Equi Join combines related records from two tables using matching values in a common column. It is one of the most frequently used SQL operations in relational databases and plays an important role in retrieving meaningful information stored across multiple tables. Understanding Primary Keys, Foreign Keys, and join conditions is essential for solving CBSE Class 12 Informatics Practices SQL queries and practical problems.