Table:
+-------+---------------------+-------+
| id | modify_date | top |
+-------+---------------------+-------+
| 1 | 2008-04-02 16:51:40 | 0 |
| 2 | 2008-04-02 16:51:40 | 0 |
| 9 | 2008-04-02 19:19:04 | 1 |
| 15 | 2008-04-08 17:54:11 | 0 |
| 16 | 2008-04-08 16:19:07 | 0 |
| 17 | 2008-04-08 16:19:11 | 0 |
| 18 | 2008-04-08 16:19:17 | 0 |
+-------+---------------------+-------+select id, modify_date, top from tableA order by top and modify_date desc
这句只能order by top,但date就不是desc
+-------+---------------------+-------+
| id | modify_date | top |
+-------+---------------------+-------+
| 9 | 2008-04-02 19:19:04 | 1 |
| 1 | 2008-04-02 16:51:40 | 0 |
| 42 | 2008-04-08 19:39:12 | 0 |
| 41 | 2008-04-08 18:54:55 | 0 |
| 27 | 2008-04-08 17:54:11 | 0 |
| 26 | 2008-04-08 16:20:14 | 0 |
| 24 | 2008-04-08 16:20:00 | 0 |
| 23 | 2008-04-08 16:19:53 | 0 |
| 22 | 2008-04-08 16:19:46 | 0 |
| 21 | 2008-04-08 16:19:40 | 0 |
| 20 | 2008-04-08 16:19:33 | 0 |
+-------+---------------------+-------+
请问怎样先排top 1,然后order by modify_date desc ?
感谢
+-------+---------------------+-------+
| id | modify_date | top |
+-------+---------------------+-------+
| 1 | 2008-04-02 16:51:40 | 0 |
| 2 | 2008-04-02 16:51:40 | 0 |
| 9 | 2008-04-02 19:19:04 | 1 |
| 15 | 2008-04-08 17:54:11 | 0 |
| 16 | 2008-04-08 16:19:07 | 0 |
| 17 | 2008-04-08 16:19:11 | 0 |
| 18 | 2008-04-08 16:19:17 | 0 |
+-------+---------------------+-------+select id, modify_date, top from tableA order by top and modify_date desc
这句只能order by top,但date就不是desc
+-------+---------------------+-------+
| id | modify_date | top |
+-------+---------------------+-------+
| 9 | 2008-04-02 19:19:04 | 1 |
| 1 | 2008-04-02 16:51:40 | 0 |
| 42 | 2008-04-08 19:39:12 | 0 |
| 41 | 2008-04-08 18:54:55 | 0 |
| 27 | 2008-04-08 17:54:11 | 0 |
| 26 | 2008-04-08 16:20:14 | 0 |
| 24 | 2008-04-08 16:20:00 | 0 |
| 23 | 2008-04-08 16:19:53 | 0 |
| 22 | 2008-04-08 16:19:46 | 0 |
| 21 | 2008-04-08 16:19:40 | 0 |
| 20 | 2008-04-08 16:19:33 | 0 |
+-------+---------------------+-------+
请问怎样先排top 1,然后order by modify_date desc ?
感谢
from tableA
order by top , modify_date desc[align=center]==== 思想重于技巧 ====
[/align]
| id | modify_date | top |
+----+---------------------+-----+
| 5 | 2008-04-09 13:42:37 | 0 |
| 4 | 2008-04-05 13:42:37 | 0 |
| 3 | 2008-04-04 13:42:37 | 0 |
| 1 | 2008-04-02 13:42:37 | 0 |
| 2 | 2008-04-03 13:42:37 | 1 |
+----+---------------------+-----+不行啊,这样排了date先我是想top的1排先,然后后面排date+----+---------------------+-----+
| id | modify_date | top |
+----+---------------------+-----+
| 2 | 2008-04-03 13:42:37 | 1 |
| 5 | 2008-04-09 13:42:37 | 0 |
| 4 | 2008-04-05 13:42:37 | 0 |
| 3 | 2008-04-04 13:42:37 | 0 |
| 1 | 2008-04-02 13:42:37 | 0 |
+----+---------------------+-----+
这样
[/align]
或参考:
http://www.csdn.net/help/over.asp
http://topic.csdn.net/u/20080110/19/7cb462f1-cac6-4c28-848e-0a879f4fd642.html
=============================================================================
问题解决,请及时结贴。
正确结贴方法:
管理帖子-->给分-->输入密码-->结贴[align=center]==== 思想重于技巧 ====
[/align]