用正则表达式进行搜索
正则表达式是用来匹配文本的特殊的串(字符集合)。
基本字符匹配
检索列prod_name包含文本1000的所有行:
regexp ‘1000’ 与文字正文1000匹配的一个正则表达式
select prod_name from products
where prod_name regexp '1000'
order by prod_name;
.是正则表达式语言中一个特殊的字符,它表示匹配任意一个字符。
select prod_name from products
where prod_name regexp '.000'
order by prod_name;
‘.000’ 能匹配1000和2000。
进行OR匹配
搜索两个串之一,使用|。
select prod_name from products
where prod_name regexp '1000|2000' order by prod_name;
<