6、用正則表達式進行搜索

一、使用MySQL正則表達式

1.1 基本字符匹配

select vend_id, prod_price, prod_name from products where prod_name regexp '1000';

1.2 進行or匹配

select vend_id, prod_price, prod_name from products where prod_name regexp '1000|2000';

1.3 匹配幾個字符之一

select vend_id, prod_price, prod_name from products where prod_name regexp '[123] ton';

1.4 匹配範圍

select vend_id, prod_price, prod_name from products where prod_name regexp '[1-5] ton';

1.5 匹配特殊字符

select vend_id, prod_price, prod_name from products where prod_name regexp '\\.';

1.6 匹配字符類

存在找出經常使用的數字、所有字母字符或所有數字字母字符等的匹配。

1.7 匹配多個實例

對匹配的數目進行更強的控制。

1.8 定位符

爲了匹配特定位置的文本。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章