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.
Thank you
ReplyDeletethank you!
ReplyDeletethanks alot
ReplyDeleteNote that for integers, you can also do an implicit cast: "SELECT numstring + 0 FROM ...".
ReplyDeletety
Deletety
Delete¡Muchas gracias!, es justo lo que necesitaba.
ReplyDeletethanks!!!!!!!!!
ReplyDeleteit did help me, thanks :)
ReplyDeletehow to convert hex value to string in sqlite.
ReplyDeleteThanks very much!
ReplyDeleteThank you very much!
ReplyDeleteThanks very much!! It's very useful.
ReplyDeleteIn fact, it also can be used at the ORDER BY clause:
ORDER BY CAST("age" as integer)
and also exist the conversion to real numeric (=float):
ORDER BY CAST("price" as real)