我运行此查询(它是一个测试数据库,所以不要为列名称笑)
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 |
+-------------------------+
答案 0 :(得分:1)
您只需输入:
即可select city,temperature from tableexample order by temperature desc;