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

If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, 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 understanding how the ORDER BY clause works in MySQL. Let's break it down:
The SQL Statement:
```sql SELECT emp_id FROM person ORDER BY emp_id; ```
This statement does the following:
1. SELECT emp_id: Retrieves the values from the column named 'emp_id'.
2. FROM person: Gets these values from a table named 'person'.
3. ORDER BY emp_id: Sorts the retrieved 'emp_id' values in ascending order (from smallest to largest).
The Answer:
Since the original set of 'emp_id' values is {9, 7, 6, 4, 3, 1, 2}, sorting them in ascending order gives us: {1, 2, 3, 4, 6, 7, 9}.
Therefore, the correct answer is Option A: {1, 2, 3, 4, 6, 7, 9}.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.