Page 1 of 1

ORDER by ??

Posted: Thu Jun 27, 2002 11:44 am
by ssand
I have a simple ORDER by:

Code: Select all

$sql = "SELECT * FROM classifieds order by run_date desc";
Is it possible to have it then sort by another column? So, the results are by run_date then ad_name (where ad_name is not desc)??

Steve

Posted: Thu Jun 27, 2002 11:50 am
by twigletmac
Have you tried,

Code: Select all

$sql = "SELECT * FROM classifieds ORDER BY run_date DESC, ad_name";
Mac

Posted: Thu Jun 27, 2002 12:03 pm
by ssand
thanks :D

Posted: Fri Oct 25, 2002 10:09 am
by Toneboy
Glad I did a search on here before posting a new topic!

Basically I have a small link system in place, and I would like to order it by the number of hits a link has had, but then if two links have had the same number of hits could you order those in ascending alphabetical order.

From the above example I'd imagine a line would look a bit like this:

"SELECT * FROM links ORDER BY hits DESC, name ASC"

Can anyone confirm this one way or another?

Posted: Fri Oct 25, 2002 11:21 am
by twigletmac
The syntax for that looks right so all you need to do is try it out on your table content.

Mac