mysql - MariaDB 错误?喜欢逃离 splinter

标签 mysql mariadb

服务器版本: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/

相关文章:

mysql - 允许 Laravel ManyToMany 迁移具有多个相同的组合

php - FIND_IN_SET 错误

mysql-server 每天 7 点删除

mysql - 无法查看 docker 容器内的表

php - Wordpress 管理员不断重定向到旧主机

mysql - 执行此选择和更新循环的更有效方法

MySQL存储过程如何生成新的auto_increment?

mysql - mysqldump --hex-blob 也可以将 DEFAULT 值转储为十六进制吗?

MySQL 查询 - 使用自连接查找最接近开始日期和结束日期的行

mysql - 如何查看 MySQL 中两个表之间的区别?