1
I have the following SQL query:
SELECT DISTINCT `user_id` AS `id`, `user_name` AS `name` FROM `users` ORDER BY `id` ASC;
That generates the output:
+----+--------+
| id | name |
+----+--------+
| 1 | Calebe |
| 2 | João |
| 3 | Lucas |
| 4 | Pedro |
+----+--------+
However, I need that determined user
come in the results, before the others.
Example: I want the user_id = 3
appears at the top. Then the result should come as follows:
+----+--------+
| id | name |
+----+--------+
| 3 | Lucas |
| 1 | Calebe |
| 2 | João |
| 4 | Pedro |
+----+--------+
How can I do it?
This will make ID 3 stay at the end of the results. You need to use a
DESC
to put you on top.– bfavaretto