表user
結構:mysql命令由兩個unixtime列組合在一起
id(PK)(int)
name(varchar)
time1(int10) unixtime
time2(int10) unixtime
SELECT * FROM `user` ORDER BY `time1` DESC,`time2` DESC
+------------------------------------------------------+
| id | name | time1 | time2 |
+------------------------------------------------------+
| 12345 | Joe | 1405605785 | 1406733506 |
| 12346 | John | 1406733506 | |
| 12347 | David | | 1405684190 |
+------------------------------------------------------+
我使用這個SQL語句:
SELECT * FROM `user` ORDER BY `time1` DESC,`time2` DESC
如何兩列的時間相結合,分類說明?
============
爲鷺更多例子回覆
+------------------------------------------------------+
| id | name | time1 | time2 |
+------------------------------------------------------+
| 12345 | Joe | 1 | 2 |
| 12346 | John | 5 | |
| 12347 | David | | 4 |
+------------------------------------------------------+
我想有點像那個(DESC)
John (time = 5)
David (time = 4)
Joe (time max value = 2)
什麼是您預期的結果? – Blank
'SELECT * FROM user ORDER BY coalesce(time1,time2)DESC' –
感謝juergen,但結果仍然像ORDER BY time1 DESC,time2 DESC – Sky