Q279
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;
A.
{1, 2, 3, 4, 6, 7, 9}
AnswerB.
{2, 1, 4, 3, 7, 9, 6}
C.
{9, 7, 6, 4, 3, 1, 2}
D.
None of the mentioned
Answer: Option A
Solution
Answer: Option A
Solution:
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}.