Forum Moderators: coopster

Message Too Old, No Replies

First sort by date, after that sort them by id descending

how to do it?

         

rowtc2

7:53 pm on Feb 18, 2009 (gmt 0)

10+ Year Member



I have products with id numbers and date added. I am sorting descending by date.
For example, i have added today 10 products and the page is showing me these 10 products, but i don't have them sorted by the last id; it looks id numbers are random.

How to do to show last 10 products by dateadded (and in this selection a second reason for sort to be descending by id)?

Actual code:


$sql = "select * from products ORDER BY dateadded DESC LIMIT 10";

tbarbedo

8:29 pm on Feb 18, 2009 (gmt 0)

10+ Year Member



$query = "SELECT * FROM products ORDER BY dateadded DESC, id DESC LIMIT 10";

That should do it for ya...