I need to use 2 order by in my procedure.
When I use only the second order by is working and not the first one.
What mistake am I doing?
Here is my procedure
BEGIN
SELECT
sd.ShopID,
@dist:= ( 6371 * acos( cos( radians(lat) ) * cos( radians( sd.Lat ) ) * cos( radians( sd.Lng ) - radians(lng) ) + sin( radians(lat) ) * sin( radians( sd.Lat ) ) ) ) AS distance
FROM
shop_details sd
WHERE
sd.Status = '1'
Order by
sd.Status Asc,
distance Asc;
END
(Don't care about the @dist formulae, as it will return the distance)
In the end I want to display the status as Ascending and distance as Ascending.
While I use
Order by
sd.Status Asc,
distance Asc
I got only distance as Asc and I got the sd.Status is not in ordered. I tried it vice versa but I got the same issue.
How can I do this without using a separate table like in this Question?
I tried this way.