mysql 1243_MySQL#1243给予EXECUTE的未知预处理语句处理程序(stmt)

  • Post author:
  • Post category:mysql


我在我安装的MySQL版本上关注这个tutorial,但它给我一个错误:

SET @sql = NULL;

SELECT

GROUP_CONCAT(DISTINCT

CONCAT(

‘MAX(IF(property_name = ”’,

property_name,

”’, value, NULL)) AS ‘,

property_name

)

) INTO @sql

FROM

properties;

SET @sql = CONCAT(‘SELECT item_id, ‘, @sql, ‘ FROM properties GROUP BY item_id’);

PREPARE stmt FROM @sql;

EXECUTE stmt;

DEALLOCATE PREPARE stmt;

我在phpMyAdmin的SQL编辑器上粘贴它.

我听从了这个建议.没有显示错误,但结果如下:

SELECT item_id

,MAX(IF(property_name = ‘color’, value, NULL)) AS color

,MAX(IF(property_name = ‘size’, value, NULL)) AS size

,MAX(IF(property_name = ‘weight’, value, NULL)) AS weight

FROM properties GROUP BY item_id

解决方法:

如果你有权访问MySQL命令行,我想你会发现你的SQL代码没问题(只要@sql不等于NULL),问题就在于phpMyAdmin.另一个想法是将代码包装在存储过程中,然后调用该过程.

标签:mysql,sql

来源: https://codeday.me/bug/20190529/1178664.html



版权声明:本文为weixin_32136817原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。