首页 > SQLServer怎么查询某字段中第一个字符为数字的记录?

SQLServer怎么查询某字段中第一个字符为数字的记录?

比如说:查询字段中第一个字符不以"A","B","C","D",E","F"开头的字母

除了

select * from [table] where  t not like 'A%' and t not like 'B%' and t not like 'C%' and t not like 'D%' and t not like 'E%' and t not like 'F%'

这种写法之外还有其他的写法吗?我在程序中处理最好不能使用"AND",可以用正则解决吗?


应该可以使用正则的


在mysql中是可以使用正则匹配的,但是在sql server 中是没有的,不过可以采用patindex;
在条件子句中加入WHERE patindex("%[A,B,C]%",字段) !> 0。
可以参考链接描述


where id like '[0-9]%'


select *from [table] where t RLIKE '^[0-9]';

have a try

【热门文章】
【热门文章】