Examveda

Which clause is used to sort a UNION result as a whole?

A. LIMIT

B. ORDER BY

C. GROUP BY

D. SORT

Answer: Option B

Solution (By Examveda Team)

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.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous