如何检查值是否是 SQLite 中的数字 [英] How to check if a value is a number in SQLite

查看:29
本文介绍了如何检查值是否是 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"

这篇关于如何检查值是否是 SQLite 中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆