William Burnside
William Burnside

Reputation: 59

MySQL Orderby Multiple Variables

I was wondering if I can orderby multiple colums. This is my current code but it gives me an error:

$query="SELECT * FROM tickets WHERE User='$usersess' ORDER BY Status ASC AND Id DESC AND UNIXtime DESC";

Can I have it order the rows in that particular order of importance with the induvidual DESC and ASC to each thing? This a complicated question and I am not sure if I am explaining it well. Let me know if you don't know what I am talking about :)

Thanks

Upvotes: 0

Views: 1006

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

Do it as:

$query="SELECT * FROM tickets WHERE User='$usersess' ORDER BY Status ASC, Id DESC, UNIXtime DESC";

Upvotes: 7

Related Questions