Reputation: 7257
I have news items that when created adds the time of creation date/time in unix timestamp format into the database. If i wanted to order by most recent first would i use ASC or DESC in my mysql query?
Thanks everyone for replying. I understand now. I will make Sarfraz answer the accepted solution as he was first to reply but thanks to everyone else to :) . Have to wait 11 minutes before i can accept it as a solution.
Upvotes: 16
Views: 44465
Reputation: 5059
You should perform a SQL Query like below
SELECT * FROM News ORDER BY date DESC
Upvotes: 6
Reputation: 62392
DESC
will put the largest first, which would be the most recent.
Upvotes: 2
Reputation: 360642
DESC - timestamps are "higher = newer" number. So sorting by DESC(ending) will put the highest (newest) entries first.
Upvotes: 30
Reputation: 50592
Unix timestamp is number of seconds since the epoch (Dec. 1969). So, newer posts have a higher number, thus, sort DESC
.
Upvotes: 2
Reputation: 382696
If i wanted to order by most recent first would i use ASC or DESC in my mysql query?
You would order by DESC
for the most recent info or higher date.
Upvotes: 2