How would I show the person logged at the top of the list

0

I'm trying to set up a SELECT that displays the person at the top of the list, so I've been showing it at the end of all "SELECT * FROM usuarios ORDER BY id != ? DESC" , I'll give an example, I have a div that shows the names of people logged in Bruno(eu), maria, rosa, joaquina etc.... want to show the name of the person who is always logged on above the others how would I mount this select ?

    
asked by anonymous 15.03.2018 / 15:36

1 answer

1

You can use a case.:

SELECT * 
FROM usuarios 
ORDER BY CASE 
    WHEN id == ? THEN 0
    ELSE 1
END 
    
15.03.2018 / 15:54