Which two statements about subqueries are true? (Choose two.)

  1. A single row subquery can retrieve data from only one table.

  2. A SQL query statement cannot display data from table B that is referred to in its subquery, unless table B is included in the main query's FROM clause.

  3. A SQL query statement can display data from table B that is referred to in its subquery, without including table B in its own FROM clause.

  4. A single row subquery can retrieve data from more than one table.

  5. A single row subquery cannot be used in a condition where the LIKE operator is used for comparison.

  6. A multiple-row subquery cannot be used in a condition where the LIKE operator is used for comparison.


Correct Option: B,D

AI Explanation

To answer this question, we need to understand the concept of subqueries.

A subquery is a query that is nested within another query. It is used to retrieve data from one or more tables and is enclosed within parentheses.

Let's go through each option to understand which are true about subqueries:

Option A) A single row subquery can retrieve data from only one table. This statement is false. A single row subquery can retrieve data from multiple tables as long as they are related through a common column.

Option B) A SQL query statement cannot display data from table B that is referred to in its subquery unless table B is included in the main query's FROM clause. This statement is true. When a subquery references a table, that table must be included in the main query's FROM clause for the data to be displayed.

Option C) A SQL query statement can display data from table B that is referred to in its subquery without including table B in its own FROM clause. This statement is false. To display data from table B that is referred to in a subquery, table B must be included in the main query's FROM clause.

Option D) A single row subquery can retrieve data from more than one table. This statement is true. A single row subquery can retrieve data from multiple tables if they are related through a common column.

Option E) A single row subquery cannot be used in a condition where the LIKE operator is used for comparison. This statement is false. A single row subquery can be used in a condition where the LIKE operator is used for comparison.

Option F) A multiple-row subquery cannot be used in a condition where the LIKE operator is used for comparison. This statement is false. A multiple-row subquery can be used in a condition where the LIKE operator is used for comparison.

Based on the explanations above, the two true statements about subqueries are:

B. A SQL query statement cannot display data from table B that is referred to in its subquery unless table B is included in the main query's FROM clause. D. A single row subquery can retrieve data from more than one table.

Therefore, the correct answer is B and D.

Find more quizzes: