您的位置:首页 > Web前端

Journey of Life: sqlite 3 string to integer conversion, similar to C function atoi

2013-01-07 10:25 453 查看
Journey of Life: sqlite 3 string to integer conversion, similar to C function atoi

sqlite 3 string to integer conversion, similar to C function atoi

In sqlite3, if you have a column defined as string, but you want to use it as integer when doing comparison, you can do the following to convert it.

CAST(expr AS type)

For example: you have a column named "version", and you stored value "11" in it. Now you can convert that to integer by doing:

Select * from mytable where CAST(version as integer)>=11;

Hope this helps you.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: