问题
i'm a bit stomped..
I'm trying to achieve a fairly simple logic..
I have a "user_sessions" table with log_in and log_out (int, epoch time stamps)
userID | log_in | log_out
trying to show the RECENT activities, I need to list all the sessions in DESCENDING ORDER based on the LATEST ACTIVITY, and this could either be log_in or log_out.. and this is where i'm stomped. I tried different ORDER and SORT methods... I'm just not getting it.
回答1:
SELECT *
FROM user_sessions
ORDER BY GREATEST(log_in, log_out) DESC
来源:https://stackoverflow.com/questions/21618224/mysql-order-a-table-using-2-columns-in-descending-order