Q1
True / FalseA subquery in MySQL can be used in the WHERE clause to filter results.
In MySQL, subqueries can be used in various clauses including WHERE, FROM, and SELECT. When used in the WHERE clause, they help in filtering results based on conditions that involve another query.
Q2
True / FalseSubqueries in MySQL must always be placed in parentheses.
Subqueries in MySQL need to be enclosed in parentheses to distinguish them from the main query and to ensure correct execution.
Q3
True / FalseA subquery can return multiple columns in MySQL.
A subquery used in the WHERE clause or as a scalar value must return a single column. If multiple columns are needed, the subquery should be used in the FROM clause or as a derived table.
Q4
True / FalseA subquery in MySQL can be used in the SELECT clause to compute a value for each row.
Subqueries can be used in the SELECT clause to compute a value for each row of the result set. For example, you might use a subquery to return an aggregate value that is displayed alongside the main query results.
Q5
True / FalseCorrelated subqueries in MySQL can reference columns from the outer query.
Correlated subqueries in MySQL are dependent on columns from the outer query. They execute once for each row processed by the outer query and can reference outer query columns to filter results.
Q6
True / FalseMySQL supports using subqueries in the HAVING clause.
MySQL allows the use of subqueries in the HAVING clause. This is useful for filtering groups of results based on conditions that involve aggregate functions.
Q7
True / FalseIn MySQL, a subquery in the FROM clause is known as a derived table or a common table expression (CTE).
In MySQL, subqueries in the FROM clause are known as derived tables. Common Table Expressions (CTEs) are supported in MySQL 8.0 and later, and are defined using the WITH clause.
Q8
True / FalseYou can use a subquery in MySQL to update multiple rows in the parent query.
MySQL allows subqueries in the UPDATE statement, which can be used to update multiple rows based on the result of the subquery.
Q9
True / FalseSubqueries in MySQL are executed only once, regardless of the number of times they are referenced.
In MySQL, the execution behavior of subqueries depends on their type and context. For correlated subqueries, they are executed multiple timesโonce for each row processed by the outer query.
Q10
True / FalseIn MySQL, the EXISTS operator can be used in a subquery to test for the presence of rows that meet certain criteria.
The EXISTS operator in MySQL is used in subqueries to check if the subquery returns any rows. It returns TRUE if the subquery contains any rows and FALSE otherwise.