title: Why is my Custom SQL query (which works fine outside of Tableau) failing in Tableau?
body: <p>My query below runs fine in mysql client (Heidi) but errors out in Tableau.  I've looked here and in the Tableau Community site and the only suggestion I see is to take out semicolons.  I've tried that to no avail.  I am connected just fine to my database through Tableau - I can see the tables and other queries run without a problem.  Any ideas on what might be the problem here? I'm running Tableau 8.2.  Thanks!</p>
  
  <pre><code>SET @sql=NULL;
  
  SELECT
  Group_Concat(Distinct CONCAT(
  'MAX(IF(wsd.cid = ''', wc.cid, ''', wsd.data, NULL)) AS    ''',wc.name,'',''''))
  INTO @sql
  FROM webform_component wc
  WHERE wc.nid = 107;
  
  SET @sql = Concat('SELECT wsd.sid,',@sql,'
  FROM webform_submitted_data wsd
  LEFT Join webform_component AS wc ON wsd.cid=wc.cid
  WHERE wsd.nid = 107 AND wsd.sid &gt;= 14967
  GROUP BY wsd.sid');
  
  PREPARE stmt FROM @sql;
  EXECUTE stmt;
  DEALLOCATE PREPARE stmt; 
  </code></pre>