Converting text to int in sqlite when querying

c#, sqlite

Solution

You need to cast in `where` clause, not where you are selecting it.

string sql4 = "select seq, maxLen from abc where CAST(maxLen as INTEGER) > 30";

Also in your current `cast` version it will not work since `CAST` works for a single field.

For your question:

How would I also convert the text to double

cast it to REAL like:

CAST(maxLen as REAL)

Problem

I want to convert both of the following columns to integer (they were placed as text in the SQlite db) as soon as I select them. ``` string sql4 = "select seq, maxLen from abc where maxLen > 30"; ``` I think it might be done like this..(using cast) ``` string sql4 = "select cast( seq as int, maxLen as int) from abc where maxLen > 30"; ``` Not sure if it's right as I seem to be getting a syntax error. How would I also convert the text to double

Original source