Q603
If emp_id contain the following set 1, 2, 2, 3, 3, 1, what will be the output on execution of the following MySQL statement? SELECT emp_id FROM person ORDER BY emp_id;
A.
{1, 1, 2, 2, 3, 3}
AnswerB.
{1, 2, 3, 3, 2, 1}
C.
{2, 2, 1, 1, 3, 3}
D.
None of the mentioned
Answer: Option A
Solution
Answer: Option A
Solution:
This question tests your understanding of how the ORDER BY clause works in MySQL.
Let's break it down:
* The SQL statement: * `SELECT emp_id`: This part selects the 'emp_id' column from the table. * `FROM person`: This specifies the table called 'person' to get the data from. * `ORDER BY emp_id`: This is the key! It instructs MySQL to arrange the selected 'emp_id' values in ascending order.
* The `emp_id` set: {1, 2, 2, 3, 3, 1}.
* The output: The SQL statement will sort this set of 'emp_id' values in ascending order, resulting in: * {1, 1, 2, 2, 3, 3}
Therefore, the correct answer is Option A.