I have a table with 2 dates - the ADDDATE and UPDATEDATE.
When an item is added, the ADDDATE is the current date and the UPDATEDATE is 0000-00-00.
I need to ORDER BY
the SQL command and get the best date of those 2.
For example if ADD=12/1/2010 and UPDATE=30/6/2010,
the UPDATE DATE is best (newest).
Any advice?
Use GREATEST to find the newest date:
ORDER BY GREATEST(UPDATEDATE, ADDDATE)
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