How do I check if a string contains a number

前端 未结 4 1455
北海茫月
北海茫月 2021-01-12 10:34

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.

Examples:

\'test\' = no numbers.

4条回答
  •  既然无缘
    2021-01-12 11:20

    Using a regular expression:

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

    Not using regular expressions:

    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%'
    

提交回复
热议问题