regexp '^a' 表示以a開(kāi)頭
regexp ‘a(chǎn)$’ 表示以a結(jié)尾
regexp ' a'表示包含a
實(shí)例
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開(kāi)頭的
select author from tcount_tbl where author regexp '^zhang';
+----------+
| author |
+----------+
| zhangsan |
| zhanger |
+----------+
2 rows in set
以er結(jié)尾的
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