MySQL 判断字段是否包含数字或者纯数字

使用mysql原生函数FIND_IN_SET查询包含某个数字

select * from text where find_in_set(1,name)

使用regexp正则匹配纯数字

select * from text where (name REGEXP '[^0-9.]')=0;

当 REGEXP ‘[^0-9.]’ 结果为 0 ,代表为纯数字
当 REGEXP ‘[^0-9.]’ 结果为1 ,代表不为纯数字

使用regexp正则匹配字段值不包含数字

select * from text where name NOT REGEXP '[0-9]+';


 

猜你喜欢

转载自blog.csdn.net/weixin_42056745/article/details/132061280
今日推荐