Regular expressions inside SQL Server

前端 未结 5 1102
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 14:34

I have stored values in my database that look like 5XXXXXX, where X can be any digit. In other words, I need to match incoming SQL query strings li

5条回答
  •  無奈伤痛
    2020-12-08 15:32

    Try this

    select * from mytable
    where p1 not like '%[^0-9]%' and substring(p1,1,1)='5'
    

    Of course, you'll need to adjust the substring value, but the rest should work...

提交回复
热议问题