PDA

View Full Version : Order By



agent007
August 10th, 2002, 11:48
Hm, okay, is it possible to use two ORDER BY commands in an SQL statement? For example:

mysql_query("SELECT * FROM pmessage WHERE username = '$username' ORDER BY date,sticky_status DESC");

Right now, I'm (trying) to make a PHP private message script for my site. There's an option for users to pin the message to the top of their inbox. Right now, if there is a ,sticky_status after the ORDER BY date, the messages go in reverse order (instead of going from newest -> oldest, they go oldest -> newest), so it's a bit strange. if the ,sticky_status isn't there, the messages are in correct order by the pinned posts won't be at the top.

If you don't understand, I'll try to elaborate even more. :P

Anyone? :)

agent007
August 10th, 2002, 13:00
Never mind. I found a way.