Updated on 2026-11-06 GMT+08:00

INNER JOIN

Function

An INNER JOIN combines rows from two tables that satisfy the join condition into a result set. Only records that meet the JOIN condition in both tables are returned.

Syntax

SELECT attr_expr_list FROM table_reference
  {JOIN | INNER JOIN} table_reference ON join_condition;

Parameters

Parameter

Description

attr_expr_list

The list of query column expressions, specifying the columns to be returned.

table_reference

The table name or subquery to be joined. Must be an existing table. Otherwise, an error is reported.

JOIN / INNER JOIN

Inner join keywords. Only records that satisfy the JOIN condition in the participating tables are displayed. Both have the same semantics.

join_condition

The join condition, typically an equality comparison expression between columns of the two tables.

ON

The keyword specifying the join condition.

Precautions

  • The tables to be joined must already exist. Otherwise, an error is reported.
  • More than two tables can be joined in a single query by using multiple JOIN clauses sequentially.

Example

Join the student_info and course_info tables by matching course IDs to view student names and their selected course names.

SELECT student_info.name, course_info.courseName FROM student_info JOIN course_info ON student_info.courseId = course_info.courseId;

Equivalent syntax:

SELECT student_info.name, course_info.courseName FROM student_info INNER JOIN course_info ON student_info.courseId = course_info.courseId;