MySQL query working in Workbench but not on server
<p>This is the query I'm using:</p>

<pre><code>SELECT q.questions 
    ,a2.answers answer
    ,a.tally tally
FROM (
    SELECT idquestions
        ,MAX(tally) tally
    FROM answers
    GROUP BY idquestions
    ) a
LEFT JOIN (
    SELECT idanswers
        ,idquestions
        ,answers
        ,tally
    FROM answers
    ) a2 ON a2.idquestions = a.idquestions
    AND a2.tally = a.tally
LEFT JOIN questions q ON q.idquestions = a.idquestions
</code></pre>

<p>When called in Workbench, it does exactly as expected, but when called from my Node server, I get an empty response.</p>

<p>(EDIT) Here's the entire Node route:</p>

<pre><code>var data = "";
connection.query("SELECT q.questions, a2.answers answer, a.tally tally FROM (SELECT idquestions, MAX(tally) tally FROM answers GROUP BY idquestions) a LEFT JOIN (SELECT idanswers, idquestions, answers, tally FROM answers) a2 ON a2.idquestions = a.idquestions AND a2.tally = a.tally LEFT JOIN questions q ON q.idquestions = a.idquestions",
      function(err, rows, fields){
    if(rows.length != 0){
        data = rows;
        res.json(data);  
    }else{
        data = 'No data Found..';
        res.json(data);
    }
      res.end();
});
</code></pre>

<p>});</p>