I have a mysql query which runs fine on workbench.
But it gives error when i try to execute it in nodejs where i am using npm module mysql.
I have tried using backticks but to no help.
sqlMessage:"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 @PivotQuery = CONCAT('SELECT Country,', @PivotQuery, ' FROM TestEmployee GRO' at line 1"
SELECT GROUP_CONCAT(CONCAT(' MAX(IF(State= ''',t.State,''', Salary, NULL)) AS ',t.State)) INTO @PivotQuery FROM (SELECT State FROM TestEmployee GROUP BY State) t; SET @PivotQuery = CONCAT('SELECT Country,', @PivotQuery, ' FROM TestEmployee GROUP BY Country'); PREPARE statement FROM @PivotQuery; EXECUTE statement; DEALLOCATE PREPARE statement;