首页 > 解决方案 > mysql连接带有数字变量的json路径失败

问题描述

以下语句将正确执行:

select json_contains_path('{"12":12}','one',concat('$."',12,'"'));

但以下将失败并出现错误cant create json with binary string::

prepare stmt from 'select json_contains_path(\'{"12":12}\',\'one\',concat(\'$."\',?,\'"\'))';
set @n=12;
execute stmt using @n;

这是为什么?我认为它们与变量替换是一样的

标签: mysqlprepared-statement

解决方案


推荐阅读