Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert string to int inside WHERE clause of SQLITE statment

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;

like image 905
Banned_User Avatar asked Oct 23 '14 06:10

Banned_User


People also ask

Can we convert string to int in SQL?

CAST and CONVERT can be used to convert a string to a number of any data type. For example, you can convert a string to a number of data type INTEGER. TO_DATE converts a formatted date string to a date integer. TO_TIMESTAMP converts a formatted date and time string to a standard timestamp.

How do I convert a text to number in SQL?

The TRY_PARSE() function can convert any string value to Numeric or Date/Time format.

Can you use CAST in WHERE clause?

You can cast data into BINARY, CHAR, DATE, DATETIME, TIME, DECIMAL, SIGNED, UNSIGNED data types. mysql> select cast(1 as char) from sales; You can also use MySQL CAST in WHERE clause.


1 Answers

Use CAST(reputation AS INTEGER).

like image 129
Anik Islam Abhi Avatar answered Oct 06 '22 00:10

Anik Islam Abhi