Answer the question
In order to leave comments, you need to log in
Set up sorting on the site?
In general, I'm doing sorting on the site, I'm testing, and I don't understand one thing. Sorting for three fields - name mail and status. The name and mail of the norms work, i.e. when sorting name sort ASC, Vasya's first position, when clicking on name sort DESC, Vasya becomes the last one. All right. And the status field has the values 1 and 0, and when sorting status sort ASC - Olya is the last one, but when status sort DESC she should be the first, but this is not so. I don't understand why.. or is it supposed to be like this? How then to sort a field with such values?
Answer the question
In order to leave comments, you need to log in
In your case, you need to do multiple sorting if the sorting is by the status field.
I would choose two fields - status and ID.
Sort by status in ascending order would look like this:
ORDER BY status ASC, id ASC
Descending would look like this:
ORDER BY status DESC, id DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question