Subquery Nested by FROM

Function

This statement is used to nest subquery by FROM and use the subquery results as the data source of the external SELECT statement.

Syntax

1
SELECT [ALL | DISTINCT] attr_expr_list FROM (sub_query) [alias];

Keyword

Precautions

Example

To return the names of students who select the courses in the course_info table and remove the repeated records using DISTINCT, run the following statement:

1
2
SELECT DISTINCT name FROM (SELECT name FROM student_info
  JOIN course_info ON student_info.courseId = course_info.courseId) temp;