1
I have a query (select nome from coisas;
) that returns to me for example:
escova
mesa
cadeira
garfo
How do I make so that if there is a "chair" in the results, it always appears first, and the others do not matter the order, but preferably order by name.
I don’t get it, what it’s like
SELECT nome FROM coisas
and returns several results, can explain better?– Woton Sampaio
As per closing link:
ORDER BY nome != "cadeira", nome
, brings chair first and the rest alphabetical order. If the order of rest does not matter, can simplify:ORDER BY nome != "cadeira"
orORDER BY nome = "cadeira" DESC
– Bacco
In this case the order of
SELECT
no longer does what is necessary? LikeSELECT cadeira, escova, mesa, garfo FROM ...
– Woton Sampaio
@Bacco was exactly what I needed! If you can post as an answer for me to accept. Thank you.
– nltw
Closing as a duplicate causes visitors to find the original answer in the other post, and your question serves as an index. Here we avoid duplicating solutions in different posts for organization (so that all users find the grouped solutions). When you have a little more points you can vote positive for all the answers that help you, even in other posts.
– Bacco
Opa, quiet, did not know how to search, but really is duplicated.
– nltw
When you have additional questions about the subject, you can leave a comment here or in the original answers there. And for other questions, feel free to open new posts.
– Bacco