doc-exports/docs/dli/sqlreference/dli_08_0166.html
Su, Xiaomeng 04d4597cf3 dli_sqlreference_0511_version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2023-11-02 14:34:08 +00:00

4.2 KiB

INNER JOIN

Function

This statement is used to join and return the rows that meet the JOIN conditions from two tables as the result set.

Syntax

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

Keyword

JOIN/INNER JOIN: Only the records that meet the JOIN conditions in joined tables will be displayed.

Precautions

  • The to-be-joined table must exist. Otherwise, an error is reported.
  • INNER JOIN can join more than two tables at one query.

Example

To join the course IDs from the student_info and course_info tables and check the mapping between student names and courses, run the following statement:

1
2
SELECT student_info.name, course_info.courseName FROM student_info
  JOIN course_info ON (student_info.courseId = course_info.courseId);