【发布时间】:2017-09-10 13:44:07
【问题描述】:
大家好,我在对名为“change”的列进行排序时遇到问题,该列是数据库中数据类型为“FLOAT”的保留字。
尝试了不同的方法,但仍然无法得到它。
"select * from data order by CAST('change' AS SIGNED) DESC";
"select * from data order by ABS(change) DESC";
"select * from data order by ABS(change - float) DESC";
"select CAST(change as float) AS ABC* from data order by ABC DESC";
我尝试了很多不同的组合,但仍然没有运气enter image description here
这是我的示例数据库的图片 提前谢谢你!
【问题讨论】:
-
MySQL 使用反引号作为分隔标识符。
-
"但还是没有运气" -- 什么运气不好?在排序?还是您遇到语法错误?
-
大多数 dbms 都有 ANSI/ISO SQL 标准的双引号,即
"CHANGE"。 -
使用不带双引号的第一个查询(select * from data order by CAST('change' AS SIGNED) DESC;),使用 mysql server 5.7 在我的工作台 6.3 上成功运行
标签: mysql sql casting floating-point