MySQL#1243提供给EXECUTE的未知预准备语句处理程序(stmt) [英] MySQL #1243 Unknown prepared statement handler (stmt) given to EXECUTE

查看:921
本文介绍了MySQL#1243提供给EXECUTE的未知预准备语句处理程序(stmt)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的教程上已安装的MySQL版本,但抛出一个错误:

I am following this tutorial on my installed version of MySQL, but it's throwing me an error:

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编辑器中.

I am pasting it on SQL editor in phpMyAdmin.

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

I followed the suggestion. No errors shown but here's the result:

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.另一个想法是将代码包装到存储过程中,然后CALL该过程.

If you have access to a MySQL command-line, I think you'll find your SQL code is fine (as long as @sql doesn't equal NULL) and the issue is with phpMyAdmin. Another idea is to wrap the code in a stored procedure and then CALL the procedure.

这篇关于MySQL#1243提供给EXECUTE的未知预准备语句处理程序(stmt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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