mysql> select * from t;
+------+----------+
| id | name |
+------+----------+
| 1 | tommy |
| 2 | jimmy |
| 3 | lily |
| 4 | lucy |
| 5 | **test** |
+------+----------+
5 rows in set (0.01 sec)mysql> select * from t where name regexp ("^\\*{2}test\\*{2}$");
+------+----------+
| id | name |
+------+----------+
| 5 | **test** |
+------+----------+
1 row in set (0.02 sec)特殊字符要用"\"进行转义,所以要用"\*"来表示"*",但是在mysql中"\"本身也是一个特殊字符,因此要用两个"\\".
+------+----------+
| id | name |
+------+----------+
| 1 | tommy |
| 2 | jimmy |
| 3 | lily |
| 4 | lucy |
| 5 | **test** |
+------+----------+
5 rows in set (0.01 sec)mysql> select * from t where name regexp ("^\\*{2}test\\*{2}$");
+------+----------+
| id | name |
+------+----------+
| 5 | **test** |
+------+----------+
1 row in set (0.02 sec)特殊字符要用"\"进行转义,所以要用"\*"来表示"*",但是在mysql中"\"本身也是一个特殊字符,因此要用两个"\\".
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货