Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql查询:按列分组_Mysql_Database_Group By_Sql Order By - Fatal编程技术网

mysql查询:按列分组

mysql查询:按列分组,mysql,database,group-by,sql-order-by,Mysql,Database,Group By,Sql Order By,我得到了这个DB: | id | sl_address | sl_type | |---------|-------------|--------------| | 1 | Street 1 | GDS | | 2 | Place 3 | Standard | | 3 | Highway 9 | Excellent | | 4 | Street 2 | Excel

我得到了这个DB:

| id      | sl_address  | sl_type      | 
|---------|-------------|--------------|
|       1 |   Street 1  |    GDS       |
|       2 |   Place 3   |    Standard  |
|       3 |   Highway 9 |    Excellent |
|       4 |   Street 2  |    Excellent |
|       5 |   Square 3  |    GDS       |
|       6 |   Plaza 7   |    Standard  |
|       7 |   Street 3  |    Excellent |
我想按sl_类型显示结果组,但不按字母顺序(标准、GDS、优秀)。

您可以使用


请注意,这样做将意味着不在该列表中的sl_类型的值将被排序到第一个位置

期望的结果是什么?太好了!谢谢你,这很有效!
SELECT *
FROM SomeTable
ORDER BY FIELD(sl_type, 'Standard', 'GDS', 'Excellent')