I have an elasticsearch variable which I have included in MySQL query. But the MySQL query is failing in case the variable is empty. I am getting the following error
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 ‘))’ at line 1
How can we fix this issue? Any suggestions should be helpful
if Isnull($unused_users) or len($unused_users) = 0
begin
select count(name)
from users
where (name IN ($users) )
end
else
begin
select count(name)
from users
where (name IN ($users) AND name NOT IN ($unused_users))
end
or whatever it is for your mysql sql query language.
your question is mysql and not grafana, so for better expertise post ina mysql forum.
@yosiasz I posted in grafana since the variable does not return a null or empty string when nothing matches. It just returns an empty which will cause an issue in MySQL or any data storage we are using.