MySQL determines whether a field contains numbers or pure numbers

Use the mysql native function FIND_IN_SET to query a number that contains a certain number

select * from text where find_in_set(1,name)

Use regexp to match pure numbers

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

When the result of REGEXP '[^0-9.]' is 0, it means it is a pure number
When the result of REGEXP '[^0-9.]' is 1, it means not is a pure number

Use regexp to match field values ​​that do not contain numbers

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


 

Guess you like

Origin blog.csdn.net/weixin_42056745/article/details/132061280