sql中的字符串转数字

2018-03-14  本文已影响73人  落寒z

sql语句中字符串转数字的几种方式-----升序方式排列

1.CAST(ordernum AS SIGNED integer)

SELECT ordernum FROM OfficeMenu ORDER BY CAST(ordernum AS SIGNED integer) asc;

2.CAST(ordernum AS SIGNED)

SELECT ordernum FROM OfficeMenu ORDER BY CAST(ordernum AS SIGNED) asc;

3."123"+0

SELECT ordernum FROM OfficeMenu ORDER BY ordernum+0 asc;
  1. 隐式转换 -"123"
SELECT ordernum FROM OfficeworkMenu ORDER BY -ordernum desc;
上一篇下一篇

猜你喜欢

热点阅读