title: Why query is showing system error?
body: <p>I have a query, I want to write it in php but its showing error.</p>
  
  <p>My query is like below:</p>
  
  <pre><code>$exe1 = mysql_query("
  SELECT
    GROUP_CONCAT(DISTINCT
      CONCAT(
        'SUM(CASE WHEN `size_name` = ''',
        `size_name`,
        ''' THEN Quantity ELSE 0 END) AS `',
        `size_name`, '`'
      )
    ) INTO @sql
  FROM Size;
  
  SET @sql = CONCAT('SELECT st.Style , ', @sql, '
                    FROM Size s
                    JOIN Style st ON s.style_id = st.id
                     GROUP BY st.Style 
                    ');
  
  PREPARE stmt FROM @sql;
  EXECUTE stmt;") or die(mysql_error());
  </code></pre>
  
  <p>But its showing the message</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'SET @sql = CONCAT('SELECT st.Style , ', @sql, ' FROM Size s ' at
    line 12</p>
  </blockquote>
  
  <p>I just dont know how to solve this error. Can anyone please help me to solve this problem?</p>