Mysql,如何改变"命令"这个查询?

时间:2018-02-02 20:56:53

标签: mysql sql

我运行此查询(它是一个测试数据库,所以不要为列名称笑)

mysql> select concat (SPACE(temperature),city) as city,temperature from tableexample order by temperature desc;
+------------------------------------------+------------+
| city                                     | temperature|
+------------------------------------------+------------+
|                                Cape Town |         32 |
|                       Paris              |         22 |
|                Rome                      |         15 |
|             New York                     |         12 |
|            London                        |         11 |
+------------------------------------------+------------+
5 rows in set (0,00 sec)

如果我删除SPACE,则输出将数字放在City

之前

我想要这样的输出,该怎么办?

+-------------------------+
| city      | temperature |
+-------------------------+
|Cape Town  |         32  |
|Paris      |         22  |
|Rome       |         15  |
|New York   |         12  |
|London     |         11  |
+-------------------------+

1 个答案:

答案 0 :(得分:1)

您只需输入:

即可
select city,temperature from tableexample order by temperature desc;