RIGHT OUTER JOIN
Function
A RIGHT OUTER JOIN matches records from the right table against the left table and returns all records from the right table. For records in the left table that have no matching value, the corresponding columns in the result set return NULL.
Syntax
SELECT attr_expr_list FROM table_reference RIGHT 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. |
| RIGHT OUTER JOIN | RIGHT OUTER JOIN keyword. Returns all records from the right table. Records in the left table without a matching value return NULL. RIGHT JOIN is an abbreviation of RIGHT 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.
- RIGHT JOIN is an abbreviation of RIGHT OUTER JOIN. Both have identical semantics.
- A RIGHT OUTER JOIN is symmetric to a LEFT OUTER JOIN: A RIGHT OUTER JOIN B ON ... is equivalent to B LEFT OUTER JOIN A ON ....
Example
A RIGHT OUTER JOIN is similar to a LEFT OUTER JOIN, but it returns all records from the right table (course_info). Records in the left table without a matching value will return NULL.
SELECT student_info.name, course_info.courseName FROM student_info RIGHT OUTER JOIN course_info ON student_info.courseId = course_info.courseId;
Equivalent syntax:
SELECT student_info.name, course_info.courseName FROM student_info RIGHT JOIN course_info ON student_info.courseId = course_info.courseId;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot