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

LEFT OUTER JOIN

Function

A LEFT OUTER JOIN matches records from the left table against the right table and returns all records from the left table. For records in the right table that have no matching value, the corresponding columns in the result set return NULL.

Syntax

SELECT attr_expr_list FROM table_reference
  LEFT OUTER 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.

LEFT OUTER JOIN

LEFT OUTER JOIN keyword. Returns all records from the left table. Records in the right table without a matching value return NULL. LEFT JOIN is an abbreviation of LEFT OUTER JOIN.

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.
  • LEFT JOIN is an abbreviation of LEFT OUTER JOIN. Both have identical semantics.

Example

In a LEFT OUTER JOIN, match courseId from student_info with courseId from course_info. Return the names of students who have selected courses and their selected course names. Records in the right table without a matching value will return NULL.

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

Equivalent syntax:

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