Highlighted text? Practice this concept. Highlighted passages and figures open related questions.
Practice related questions (2)Progress & bookmarks
Current section
2-2-6 Sub Reference (Subquery)
p. 275
Practice this section 2 linked exam questions with default filters
Progress
Not marked complete
Related questions in this lesson 3
Original independent IN subquery3Original correlated EXISTS definition1p. 275
2-2-6 Sub Reference (Subquery)
Sub reference (subquery) refers to searching for another table on the basis of the search results of a certain table. SELECT statement that determines the conditions is called subquery statement, while the SELECT statement that searches for the table by using the results of subquery statement is called main query statement. Subquery is broadly classified into two types.
(1) Subquery statement that can be independently executed
This subquery statement is independently executed for getting the conditions of the main query statement. In this format, subquery statement inside the parentheses ( ) is executed first, and main query statement is executed on the basis of its results.
ex21: From the “Student” table and the “Score” table, extract the names where ExaminationDate is '20XX-10-20'.
p. 276
(2) Correlation subquery (subquery statement that cannot be executed independently)
In the SQL statement of ex22, the subquery statement inside the parentheses ( ) cannot be executed independently. (Correlation name X cannot be interpreted.) Therefore, tuples of the “Student” table are fetched one at a time, and the subquery statement is executed.
p. 277
In this manner, by executing the subquery statement by using StudentNumber of all tuples, tuples to be extracted are decided.
When this example is represented without using subquery, the SQL statement is described as below. Here, note that the DISTINCT specification is omitted and (Chiyo Yamamoto) is extracted twice.
In addition, IN predicate and EXISTS predicate can be used in combination with the logical operator NOT.
Section progress
Original chapter exercises
Original chapter exercises →New FE Textbook Vol.1 · IT Fundamentals · First Edition, April 2015







