?
Which clause is used to sort a UNION result as a whole?
Answer & Solution
Correct Answer:
Option
B
This question asks about how to arrange the results of a UNION operation in MySQL.
UNION combines the results of multiple SELECT queries into a single result set. However, the combined result might not be in the desired order.
Let's look at the options:
A: LIMIT - This clause is used to limit the number of rows returned, not for sorting.
B: ORDER BY - This is the correct answer. The ORDER BY clause is used to sort the results of a query, including the results of a UNION.
C: GROUP BY - This clause is used to group rows based on specific columns, and it doesn't directly affect sorting.
D: SORT - This clause is not a valid clause in MySQL.
In summary, to sort the combined results of a UNION, you would use the ORDER BY clause.
UNION combines the results of multiple SELECT queries into a single result set. However, the combined result might not be in the desired order.
Let's look at the options:
A: LIMIT - This clause is used to limit the number of rows returned, not for sorting.
B: ORDER BY - This is the correct answer. The ORDER BY clause is used to sort the results of a query, including the results of a UNION.
C: GROUP BY - This clause is used to group rows based on specific columns, and it doesn't directly affect sorting.
D: SORT - This clause is not a valid clause in MySQL.
In summary, to sort the combined results of a UNION, you would use the ORDER BY clause.
Join the Discussion
Login to post a comment or share your explanation.
Login