MariaDB错误?像逃脱一样 [英] MariaDB Bugs? LIKE Escaping Broken

查看:139
本文介绍了MariaDB错误?像逃脱一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器版本:10.1.21-MariaDB-1〜jessie

Server version: 10.1.21-MariaDB-1~jessie

select 'a%b' like '%\%\%';
+--------------------+
| 'a%b' like '%\%\%' |
+--------------------+
|                  1 |
+--------------------+
1 row in set (0.00 sec)

like子句表示通配符+文字%+文字%",但与"a%b"匹配.

the like clause represents 'wildcard + literal % + literal %' but it matches 'a%b'.

select 'a%b' like '%\%\%\%\%\%';
+--------------------------+
| 'a%b' like '%\%\%\%\%\%' |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0.00 sec)

MySQL 5.5.38的两个语句均返回0. MariaDB的语法是否不同?

MySQL 5.5.38 returns 0 for both statements. Is the syntax of MariaDB different?

添加

@rahul指出语法错误,所以我创建了一个虚拟表并运行

@rahul pointed that the syntax is wrong, so I created a dummy table and ran

SELECT * FROM `table1` where 'a%b' like '%\%\%';

与表中的每一行匹配.

但是,当我运行时,field1 ='a%b'的行不匹配

However, a row with field1='a%b' doesn't match when I ran

SELECT * from `table` where field1 like '%\%\%';

现在要在10.1.22上进行测试.

Now going to test on 10.1.22.

推荐答案

似乎这已在10.1.22中修复.

It seems this is fixed in 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)

这篇关于MariaDB错误?像逃脱一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆