mysql中實現排序的方法有以下幾種
通過在數據表使用以下命令實現的排序
1.單列排序
SELECT * FROM test1 ORDER BY date_time
2.多列排序?
SELECT * FROM test1 ORDER BY `status`, date_time DESC
3.自定義排序
SELECT * FROM test1 ORDER BY FIELD(`status`, 3, 2, 4, 1, 5), date_time DESC
4.條件排序
SELECT * FROM test1 ORDER BY date_time < NOW(), IF(date_time < NOW(), 0, date_time), date_time DESC