title: MySQL #1243 Unknown prepared statement handler (stmt) given to EXECUTE
body: <p>I am following this <a href="http://buysql.com/mysql/14-how-to-automate-pivot-tables.html" rel="nofollow noreferrer">tutorial</a> on my installed version of MySQL, but it's throwing me an error:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>I am pasting it on SQL editor in phpMyAdmin.</p>
  
  <p>I followed the suggestion. No errors shown but here's the result:</p>
  
  <pre><code>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
  </code></pre>