ExamVeda
Login
Home
This question belongs to MySQL MySQL Miscellaneous
MySQL Miscellaneous
?

If emp_id contain the following set {1, 2, 3, 4, 1, 1}, what will be the output on execution of the following MySQL statement?
SELECT emp_id
FROM person
ORDER BY emp_id;

Answer & Solution
Correct Answer: Option A
This question is about how MySQL orders data. We have a set of employee IDs (emp_id) {1, 2, 3, 4, 1, 1} in a table called person.
The SQL statement SELECT emp_id FROM person ORDER BY emp_id; tells MySQL to:
1. Select the employee IDs (emp_id)
2. From the table called person
3. Order them by the employee ID, from smallest to largest.
Therefore, the correct output is Option A: {1, 1, 1, 2, 3, 4} because the statement sorts the IDs in ascending order.
The duplicates (1, 1, 1) are not removed by the ORDER BY clause, they just appear in the order based on their numerical value.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.