What is ‘-‘ in front of a column in mysql mean?

What is the significance of “-” (Last line of the code, before a.emp_no) in the following code? I have been trying to understand but I want sure answers. Please Help!!!!!!!!!!!!!!!!!!

SELECT *
FROM
(SELECT
    e.emp_no,
    e.first_name,
    e.last_name,
    NULL AS dept_no,
    NULL AS from_date
FROM
    employees.employees e
WHERE
    last_name = 'Denis' 
UNION SELECT
    NULL AS emp_no,
    NULL AS first_name,
    NULL AS last_name,
    dm.dept_no,
    dm.from_date
FROM
   employees.dept_manager dm) as a
ORDER BY -a.emp_no DESC;

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

if emp_no is a number – then it is asking to order by the negative of the number. you could also say

order by a.emp_no


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x