I wanna select data from table with ordering where first I'll get values with specific value.
I tried this but it didn't work:
SELECT name FROM test ORDER BY id ='d189463e-52dc-40e5-adf7-eddce74cf05e';
CodePudding user response:
use a case expression This allows you to define whatever "ordering" you want for the IDs
ORDER BY case when ID = 'd189463e-52dc-40e5-adf7-eddce74cf05e' then 1 else 2 end, ...
CodePudding user response:
I would write
ORDER BY id <> 'd189463e-52dc-40e5-adf7-eddce74cf05e'
or
ORDER BY id = 'd189463e-52dc-40e5-adf7-eddce74cf05e' DESC
because FALSE < TRUE
.