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

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.

你可能感兴趣的:(conversion)