Hi I’ve got the following stored procedure
BEGIN
SELECT
GROUP_CONCAT(
CONCAT("MAX(IF(scadenza='", scadenza, "',importo ,'')) AS '", scadenza, "'"), "
")INTO @answers
FROM (SELECT DISTINCT scadenza
FROM ripartizione_rate
WHERE preventivo = preventivoID
) A;
SET @query :=
CONCAT(
'SELECT DISTINCT condomino, anagrafica,', @answers,
'FROM ripartizione_rate
GROUP BY condomino, anagrafica
ORDER BY condomino, anagrafica'
);
PREPARE statement FROM @query;
EXECUTE statement;
END
If I pass a parameter (preventivoID) that is not in the database I get the following error instead of getting NULL:
MySQL said: #1064 - 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 'NULL' at line 1
I’m not sure why this is happening?