浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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.
posted on 2013-01-07 10:25  lexus  阅读(262)  评论(0编辑  收藏  举报