250+ TOP MCQs on Performing Multiple – Table Retrievals with Subqueries and Answers

MySQL Interview Questions and Answers for freshers focuses on “Performing Multiple – Table Retrievals with Subqueries”.

1. The facility that allows nesting one select statement into another is called __________
a) nesting
b) binding
c) subquerying
d) encapsulating

Answer: c
Clarification: The ‘subquerying’ support provided by MySQL is a capability that allows writing one ‘SELECT’ statement within parentheses and nesting within another. This allows logically selecting content from tables.

2. Which subquery returns a single value?
a) scalar
b) column
c) row
d) table

Answer: a
Clarification: The subqueries in MySQL can return different types of information. A scalar query returns a single value. Column subquery return a single column and row subquery returns a single row.

3. Usage of aggregates in WHERE clause is allowed.
a) True
b) False

Answer: b
Clarification: The usage of aggregates inside ‘WHERE’ clauses is not allowed. For example, the following statement will not work : ‘SELECT * FROM my_table WHERE attribute_name = MAX(attribute_name)’, because the MAX value is not known yet.

4. Which operators are used when a subquery returns multiple rows to be evaluated in comparison to the outer query?
a) IN and NOT IN
b) EXISTS and NOT EXISTS
c) OUTER JOIN and INNER JOIN
d) LEFT JOIN and RIGHT JOIN

Answer: a
Clarification: When there is a need to evaluate multiple rows in comparison to the outer query, the ‘IN’ and ‘NOT IN’ operators are used. They are used for testing whether a comparison value is present in a set of values.

5. The ALL subquery performs which operation?
a) row
b) column
c) table
d) database

Answer: b
Clarification: The operators ‘ALL’ and ‘ANY’ are used to perform operations on columns. They are used in conjunction with a comparison operator in order to test the result of a column subquery.

6. Which of these operators perform similar operations like ALL and ANY?
a) SOME
b) MANY
c) SELECT
d) GROUP

Answer: a
Clarification: The operators ‘SOME’, ‘ALL’ and ‘ANY’ perform operations on columns. They can filter column results. They are used in conjunction with a comparison operator in order to test the result of a column subquery.

7. Which operators test whether a subquery returns any rows?
a) IN and NOT IN
b) EXISTS and NOT EXISTS
c) PRESENT
d) ABSENT

Answer: b
Clarification: The operators ‘EXISTS’ and ‘NOT EXISTS’ operators only test whether a subquery returns any rows. If it returns a row, ‘EXISTS’ results into true and ‘NOT EXISTS’ results into false.

8. An uncorrelated subquery does not contain any reference to the values from the outer query.
a) True
b) False

Answer: a
Clarification: MySQL has two kinds of subqueries, namely, uncorrelated subquery and correlated subquery. An uncorrelated subquery does not contain any reference to the values from the outer query.

9. Which subquery cannot be executed by itself as a separate statement?
a) Correlated
b) Uncorrelated
c) EXISTS
d) NOT EXISTS

Answer: a
Clarification: An uncorrelated subquery contains references to the values from the outer query. So, it is dependent on it. Therefore, a correlated subquery cannot be executed by itself as a separate statement.

10. Which of these operators does not perform relative-value comparisons?
a) =
b) ==
c) <=
d) >=

Answer: b
Clarification: The operators =, < >, >, >=, <, and <= perform relative value comparisons in MySQL. ‘==’ is not a valid comparison operator in MySQL. Such operators are useful in filtering information from a table.

Leave a Reply

Your email address will not be published. Required fields are marked *