要用REGEXP?殺雞用牛刀
uj5u.com熱心網友回復:
我這邊測驗是沒問題的 資料庫版本mysql8如果資料庫版本不支持,可以嘗試like '%\[abc\]%'; 轉義試試
mysql> create table t4(str varchar(100));
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql>
mysql> insert into t4 values ('[abc]1111'),('1111[abc]'),('[1abc]'),('[abc1]');
Query OK, 4 rows affected (0.01 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> select * from t4;
+-----------+
| str |
+-----------+
| [abc]1111 |
| 1111[abc] |
| [1abc] |
| [abc1] |
+-----------+
4 rows in set (0.00 sec)
mysql> select * from t4 where str like '%[abc]%';
+-----------+
| str |
+-----------+
| [abc]1111 |
| 1111[abc] |
+-----------+
2 rows in set (0.00 sec)
mysql>
mysql> select * from t4 where str like '%\[abc\]%';
+-----------+
| str |
+-----------+
| [abc]1111 |
| 1111[abc] |
+-----------+
2 rows in set (0.00 sec)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/7147.html
標籤:MySQL
