起因:写sql order by一个字段,字段类型是varchar里面存储的是数字,要按数字大小排序,而不是按首字符出现先后顺序,这就需要转换
RDER
BY
CAST(
`pic_number`
AS
SIGNED)
and for reverse order
ORDER
BY
CAST(
`pic_number`
AS
SIGNED)
DESC
And it worked like a charm!
Function is as simple to use as:
CAST(
expr AS
type)
Other possible conversion types you may need are:
- BINARY[(N)]
- CHAR[(N)]
- DATE
- DATETIME
- DECIMAL[(M[,D])]
- SIGNED [INTEGER]
- TIME
- UNSIGNED [INTEGER]