我想让我的表rcarddet由“SDNO”(不是主键)以升序排序,但“0”除外。所以结果应该像这样:

1
1
2
.
.
10
0
0

我的查询现在是:
SELECT *
  FROM `rcarddet`
 WHERE `RDATE` = '2011-05-25'
   AND `RCNO` = '1'
   AND `PLACE` = 'H'
   AND `SDNO` != 0
ORDER BY `rcarddet`.`SDNO` ASC;

最佳答案

SELECT *
  FROM `rcarddet`
 WHERE `RDATE` = '2011-05-25'
   AND `RCNO` = '1'
   AND `PLACE` = 'H'
ORDER BY
  `SDNO` = 0,
  `SDNO`;

10-06 01:39