與多階選擇,所以我得到這個表:的MySQL通過
+----+---------------------+-----+----------------+ | ID | WHEN | OFF | (other..stuff) | +----+---------------------+-----+----------------+ | 1 | 2012-09-17 17:00:00 | 0 | anything1 | | 2 | 2012-09-17 18:00:00 | 0 | anything2 | | 3 | 2012-08-31 21:00:00 | 1 | blabla321 | | 4 | 2012-08-31 18:30:00 | 1 | blab32121 | +----+---------------------+-----+----------------+
我想選擇所有的密鑰,但:
- 通過時ASC與關閉= 0應該是爲了鑰匙,他們應該是 顯示的第一
- 鍵與關= 1應該是爲了通過時DESC,他們應該之後顯示 (末尾)
我想是這樣的:
(SELECT * FROM `table` WHERE `off` = 0 ORDER BY `when` ASC)
UNION
(SELECT * FROM `table` WHERE `off` = 1 ORDER BY `when` DESC)
但它不工作。
同時檢查: http://i.imgur.com/81Hzq.jpg
什麼是錯誤? – wroniasty
有沒有錯誤它只是命令everthing通過'當'ASC – borewik