你好,我正在尝试按照域名状态订购域名数据。正如你所知,域名状态DOM_EXP或DOM_DAKT适用于域名达到DOM_HELD之前,因此在域名变为DOM_HELD之前,我不关心这些状态中的哪一个。
我该如何订购这些数据?使用下面提供的选择器,我只能实现DOM_DAKT位于DOM_EXP之后,但我希望它在其中某个位置,按exp_date排序。
SELECT domain_id, status, exp_date
FROM domains
ORDER BY
field (status, 'DOM_DEL', 'DOM_HELD', 'DOM_EXP', 'DOM_DAKT'),
exp_date ASC;
+-----------+----------+---------------------+
| domain_id | status | exp_date |
+-----------+----------+---------------------+
| 2 | DOM_DEL | 2012-02-02 10:47:33 |
| 4 | DOM_HELD | 2012-02-02 10:47:38 |
| 5 | DOM_HELD | 2012-02-02 10:47:40 |
| 7 | DOM_HELD | 2012-02-02 10:47:44 |
| 1 | DOM_EXP | 2012-02-02 10:47:27 |
| 3 | DOM_EXP | 2012-02-02 10:47:35 |
| 6 | DOM_EXP | 2012-02-02 10:47:42 |
| 54 | DOM_DAKT | 2012-02-02 10:47:39 |
+-----------+----------+---------------------+
结果必须像这样
+-----------+----------+---------------------+
| domain_id | status | exp_date |
+-----------+----------+---------------------+
| 2 | DOM_DEL | 2012-02-02 10:47:33 |
| 4 | DOM_HELD | 2012-02-02 10:47:38 |
| 5 | DOM_HELD | 2012-02-02 10:47:40 |
| 7 | DOM_HELD | 2012-02-02 10:47:44 |
| 1 | DOM_EXP | 2012-02-02 10:47:27 |
| 3 | DOM_EXP | 2012-02-02 10:47:35 |
| 54 | DOM_DAKT | 2012-02-02 10:47:39 |
| 6 | DOM_EXP | 2012-02-02 10:47:42 |
+-----------+----------+---------------------+
DOM_DAKT
? - Corubba