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.
You can use the ASC and DESC keywords to specify ascending (smallest value first) or descending (largest value first) order. The default order is ascending. For DATE and DATETIME data types, smallest means earliest in time and largest means latest in time.
You can use ORDER BY ASC to order timestamp values in ascending order with TIMESTAMP() method.
The ORDER BY command is used to sort the result set in ascending or descending order. The ORDER BY command sorts the result set in ascending order by default. To sort the records in descending order, use the DESC keyword.
DESC - timestamps are "higher = newer" number. So sorting by DESC(ending) will put the highest (newest) entries first.
You should perform a SQL Query like below
SELECT * FROM News ORDER BY date DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With