Convert string to int inside WHERE clause of SQLITE statment

£可爱£侵袭症+ 提交于 2020-01-02 04:02:26

问题


I want to achieve this:

SELECT * FROM linkledger WHERE toInt(reputation) > 100;

but the function toInt doesnt exist? Is there one?

I found this now but not working, which implies i have a more fundemental problem. BECAUSE THIS IS CORRECT

SELECT * FROM linkledger WHERE cast(reputation AS INTEGER) > 100;


回答1:


Use CAST(reputation AS INTEGER).




回答2:


I will leave Anik Islam Abhi's answer as the correct one because it will apply in most cases but I just want it on record that I only managed to fix the problem by just switching the variable to int

create table foo reputation int;

And then insuring Ints were inserted... I'm not sure what was happening that the correct answer didnt solve my problem.



来源:https://stackoverflow.com/questions/26522727/convert-string-to-int-inside-where-clause-of-sqlite-statment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!