如何检查值是否是 SQLite 中的数字

如何检查值是否是 SQLite 中的数字

问题描述:

我有一列包含数字和其他字符串值(如?"、???"等)

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

是否可以在 SQLite 的 where 子句中添加是数字"条件?类似的东西:

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

select * from mytable where isnumber(mycolumn)

来自文档

typeof(X) 函数返回一个字符串,该字符串指示表达式 X 的数据类型:null"、integer"、real"、text"或blob".

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

你可以使用 where typeof(mycolumn) = "integer"