MySQL 使用正则表表达式

    MySQL仅支持多数正则表达式实现的一小部分。

用法:

       使用 regexp 关键字。

一、基本字符匹配

select prod_name from products where prod_name regexp '1000' order by prod_name;

二、进行or匹配

select prod_name from products where prod_name regexp '1000|2000' order by prod_name;

三、匹配几个字符之一

select prod_name from products where prod_name regexp '[123] Ton' order by prod_name;

四、匹配范围

select prod_name from products where prod_name regexp '[1-5] Ton' order by prod_name;

扫描二维码关注公众号,回复: 6091303 查看本文章

五、匹配特殊字符

select vend_name from vendors where vend_name regexp '\\.' order by vend_name;

猜你喜欢

转载自blog.csdn.net/hefrankeleyn/article/details/84992346