如何检查字符串是否包含数字 [英] How do I check if a string contains a number

查看:127
本文介绍了如何检查字符串是否包含数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查字符串是否包含数字.任何数字. 字符串是否为数字,而不是数字,但是如果包含一个数字.

I need to check if a string contains a number. Any number. Not wether or not the string IS a number, but if it contains one.

示例:

'test'=没有数字.

'test' = no numbers.

'test2'=包含数字.

'test2' = contains number.

推荐答案

使用正则表达式 :

SELECT *
FROM test
WHERE REGEXP_LIKE(testcol, '[[:digit:]]');

不使用正则表达式:

SELECT *
FROM test
WHERE testcol LIKE '%0%'
    OR testcol LIKE '%1%'
    OR testcol LIKE '%2%'
    OR testcol LIKE '%3%'
    OR testcol LIKE '%4%'
    OR testcol LIKE '%5%'
    OR testcol LIKE '%6%'
    OR testcol LIKE '%7%'
    OR testcol LIKE '%8%'
    OR testcol LIKE '%9%'

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

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