mysql的正则表达式

regexp '^a' 表示以a开头
regexp ‘a$’ 表示以a结尾
regexp ' a'表示包含a
实例

select * from tcount_tbl;
+----------+-------+
| author   | count |
+----------+-------+
| z        |    20 |
| a        |    20 |
| b        |     0 |
| g        |     0 |
| j        |     1 |
| s        |     1 |
| 张三     | NULL  |
| zhangsan | NULL  |
| zhanger  | NULL  |
| zer      |    10 |
+----------+-------+
10 rows in set

以zhang开头的

select author from tcount_tbl where author regexp '^zhang';
+----------+
| author   |
+----------+
| zhangsan |
| zhanger  |
+----------+
2 rows in set

以er结尾的

select author from tcount_tbl where author regexp 'er$';
+---------+
| author  |
+---------+
| zhanger |
| zer     |
+---------+
2 rows in set

包含z的

 select author from tcount_tbl where author regexp 'z';
+----------+
| author   |
+----------+
| z        |
| zhangsan |
| zhanger  |
| zer      |
+----------+
4 rows in set

你可能感兴趣的:(mysql的正则表达式)