服务器版本:10.1.21-MariaDB-1~jessie
select 'a%b' like '%\%\%';
+--------------------+
| 'a%b' like '%\%\%' |
+--------------------+
| 1 |
+--------------------+
1 row in set (0.00 sec)
like 子句表示“通配符 + 文字 % + 文字 %”,但它匹配“a%b”。
或
select 'a%b' like '%\%\%\%\%\%';
+--------------------------+
| 'a%b' like '%\%\%\%\%\%' |
+--------------------------+
| 1 |
+--------------------------+
1 row in set (0.00 sec)
MySQL 5.5.38 对两个语句都返回 0。 MariaDB 的语法有什么不同吗?
添加
@rahul 指出语法错误,所以我创建了一个虚拟表并运行了
SELECT * FROM `table1` where 'a%b' like '%\%\%';
匹配表中的每一行。
但是,当我运行时,带有 field1='a%b' 的行不匹配
SELECT * from `table` where field1 like '%\%\%';
现在准备在 10.1.22 上测试。
最佳答案
这似乎是在 10.1.22 中修复的。
Server version: 10.1.22-MariaDB-1~xenial mariadb.org binary distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select 'a%b' like '%\%\%';
+--------------------+
| 'a%b' like '%\%\%' |
+--------------------+
| 0 |
+--------------------+
1 row in set (0.00 sec)
关于mysql - MariaDB 错误?喜欢逃离 splinter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42924664/