我的表SELECT FROM表,ORDER BY IF(...)
SELECT * FROM mail;
+---------------------+---------+---------+---------+---------+---------+
| t | srcuser | srchost | dstuser | dsthost | size |
+---------------------+---------+---------+---------+---------+---------+
| 2014-05-11 10:15:08 | barb | saturn | tricia | mars | 58274 |
| 2014-05-12 12:48:13 | tricia | mars | gene | venus | 194925 |
| 2014-05-12 15:02:49 | phil | mars | phil | saturn | 1048 |
| 2014-05-12 18:59:18 | barb | saturn | tricia | venus | 271 |
| 2014-05-14 09:31:37 | gene | venus | barb | mars | 2291 |
| 2014-05-14 11:52:17 | phil | mars | tricia | saturn | 5781 |
| 2014-05-14 14:42:21 | barb | venus | barb | venus | 98151 |
| 2014-05-14 17:03:01 | tricia | saturn | phil | venus | 2394482 |
| 2014-05-15 07:17:48 | gene | mars | gene | saturn | 3824 |
| 2014-05-15 08:50:57 | phil | venus | phil | venus | 978 |
| 2014-05-15 10:25:52 | gene | mars | tricia | saturn | 998532 |
| 2014-05-15 17:35:31 | gene | saturn | gene | mars | 3856 |
| 2014-05-16 09:00:28 | gene | venus | barb | mars | 613 |
| 2014-05-16 23:04:19 | phil | venus | barb | venus | 10294 |
| 2014-05-19 12:49:23 | phil | mars | tricia | saturn | 873 |
| 2014-05-19 22:21:51 | gene | saturn | gene | venus | 23992 |
+---------------------+---------+---------+---------+---------+---------+
我有這樣
SELECT t, srcuser, dstuser, size
-> FROM mail
-> ORDER BY IF(srcuser='phil',0,1), srcuser, dstuser;
查詢將產生
+---------------------+---------+---------+---------+
| t | srcuser | dstuser | size |
+---------------------+---------+---------+---------+
| 2014-05-16 23:04:19 | phil | barb | 10294 |
| 2014-05-12 15:02:49 | phil | phil | 1048 |
| 2014-05-15 08:50:57 | phil | phil | 978 |
| 2014-05-14 11:52:17 | phil | tricia | 5781 |
| 2014-05-19 12:49:23 | phil | tricia | 873 |
| 2014-05-14 14:42:21 | barb | barb | 98151 |
| 2014-05-11 10:15:08 | barb | tricia | 58274 |
| 2014-05-12 18:59:18 | barb | tricia | 271 |
| 2014-05-14 09:31:37 | gene | barb | 2291 |
| 2014-05-16 09:00:28 | gene | barb | 613 |
| 2014-05-15 07:17:48 | gene | gene | 3824 |
| 2014-05-15 17:35:31 | gene | gene | 3856 |
| 2014-05-19 22:21:51 | gene | gene | 23992 |
| 2014-05-15 10:25:52 | gene | tricia | 998532 |
| 2014-05-12 12:48:13 | tricia | gene | 194925 |
| 2014-05-14 17:03:01 | tricia | phil | 2394482 |
+---------------------+---------+---------+---------+
我不明白如何訂購.OK,phil是感興趣的名稱.Book說,假設您想對發件人/收件人 訂單中的郵件表消息進行分類,但您想先爲特定的發件人發送消息。爲什麼我們使用0,1?
可以達到相同的結果這是否意味着我可以放'0,2'? – MishaVacic
是的我相信如此,或者「1,2」,如果這對你更有意義。 –