Devator
Devator

Reputation: 3904

MySQL sorting multiple rows

I want to sort on strProjectName and strJobName, but I want to prioritize strProjectName. Using the regular order by method: ORDER BY strProjectName, strJobName ASC does work, but not when sorting DESC, due to the fact it will sort on strJobName instead.

TL;DR: I want to sort first on strProjectName and then on strJobName. (And yes, there are more fields).

Upvotes: 0

Views: 414

Answers (2)

Casper
Casper

Reputation: 34308

You can mix ordering by different columns like so:

ORDER BY a DESC, b ASC

Upvotes: 1

dee-see
dee-see

Reputation: 24078

You have to specify ORDER BY strProjectName DESC, strJobName DESC or else ASC will be assumed for strProjectName.

Upvotes: 1

Related Questions