I’m about to make a subscriptions list to my website, but I can’t find a solution for multiple “order by” in my query, that actually works.
My current code is:
select name from data_subscriptions
where authVal="1"
order by id desc, name asc limit 100
But I only order by id desc, and not the name asc.
Database:
[1] ( id=1, authVal=1, name=Alex )
[2] ( id=2, authVal=1, name=Jens )
It shows Jens, and then Alex – What do I do wrong?
I think maybe what you wanted was this:
This amounts to order by the name but if the names are the same, then order by id
Your existing code would order by id, and if the ids are the same, then order by the name. My guess is that the ids are never the same, so it always just ends up in id order.