mysql 1243,MySQL#1243提供给EXECUTE的未知预准备语句处理程序(stmt)

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;

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

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值