Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向mysql存储过程传递重音符号时出现问题_Mysql_Stored Procedures_Procedure_Diacritics - Fatal编程技术网

向mysql存储过程传递重音符号时出现问题

向mysql存储过程传递重音符号时出现问题,mysql,stored-procedures,procedure,diacritics,Mysql,Stored Procedures,Procedure,Diacritics,如果在存储过程中运行此查询,将正确返回匹配的行 select brand from article where brand regexp '[àéëË]'; 但是如果我试着把它转换成一个动态的语句,比如 set @s=concat('select brand from article where brand regexp \'[',argument,']\''); prepare stmt from @s; execute stmt; 然后,当我将“ëË”作为参数传递给过程时,它将失败(找不

如果在存储过程中运行此查询,将正确返回匹配的行

select brand from article where brand regexp '[àéëË]';
但是如果我试着把它转换成一个动态的语句,比如

set @s=concat('select brand from article where brand regexp \'[',argument,']\'');
prepare stmt from @s;
execute stmt;
然后,当我将“ëË”作为参数传递给过程时,它将失败(找不到匹配的行)。但它不带口音(“aeE”)

[编辑]它甚至不适用于硬编码的值

set @s=concat('select brand from article where brand regexp \'[àéëË]\'');
有什么想法吗? 谢谢

入住您的桌子

我无法重现表中使用的字符集和排序规则的问题:

mysql>删除过程(如果存在)`sp_test`;
查询正常,0行受影响(0.00秒)
mysql>删除表(如果存在)`_article`;
查询正常,0行受影响,1条警告(0.00秒)
mysql>创建不存在的表“\u article”(
->`brand`VARCHAR(255)
->)默认字符集=latin1 COLLATE=latin1_bin;
查询正常,0行受影响(0.00秒)
mysql>插入到文章中`
->(`brand`)
->价值观
->     ('àéëË'),
->('aeE');
查询正常,2行受影响(0.00秒)
记录:2个重复:0警告:0
mysql>分隔符//
mysql>创建过程`sp_test`(`index`TINYINT,`argument`VARCHAR(255))
->开始
->SET@`query`:=CONCAT('SELECT','index`,'index`,'brand`)`
“>来自`\u文章`
“>其中'brand`REGEXP\'[','argument`,']\'”;
->从“查询”中准备“stmt”;
->执行'stmt';
->SET@`query`:=NULL;
->取消分配“stmt”;
->结束//
查询正常,0行受影响(0.00秒)
mysql>分隔符;
mysql>调用'spëu test'(1,'aëË');
+-------+----------+
|指数|品牌|
+-------+----------+
|     1 | àéëË     |
+-------+----------+
一行一组(0.00秒)
查询正常,0行受影响(0.00秒)
mysql>调用'sp_test'(2,'e');
+-------+-------+
|指数|品牌|
+-------+-------+
|2 | aeE|
+-------+-------+
一行一组(0.00秒)
查询正常,0行受影响(0.00秒)
mysql>调用'sp_test'(3,'a');
空集(0.00秒)
查询正常,0行受影响(0.00秒)
mysql>调用'sp_test'(4,'A');
空集(0.00秒)
查询正常,0行受影响(0.00秒)
mysql>调用'sp_test'(5'Ë');
+-------+----------+
|指数|品牌|
+-------+----------+
|     5 | àéëË     |
+-------+----------+
一行一组(0.01秒)
查询正常,0行受影响(0.01秒)
例如