Skip to content
Advertisement

How to check if a value is a number in SQLite

I have a column that contains numbers and other string values (like “?”, “???”, etc.)

Is it possible to add an “is number” condition to the where clause in SQLite? Something like:

select * from mytable where isnumber(mycolumn)

Advertisement

Answer

From the documentation,

The typeof(X) function returns a string that indicates the datatype of the expression X: “null”, “integer”, “real”, “text”, or “blob”.

You can use where typeof(mycolumn) = "integer"

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement