Hi everybody, I am new in Grafana, my question: I declared two variables and I want to use those in a where statement to update the query result
But it just does not work, those fields are strings type and I wish that the Dashboard could update with the filter change, can any one help me??? please
The database is postgreSQL
None of that worked, I finally found that, at least in postgresql connector, you can not use ‘=’ syntax to use variables, you have to use ‘in’ syntax intead, for example:
WHERE client = ‘[[variable]]’ – this doesnt work, but if you use
WHERE client in (’[[variable]]’) – that work as expected
Grafana automatically creates a quoted, comma-separated string for multi-value variables.
You need to keep in mind variable auto quotes (so your problem is a Grafana feature, not a bug). Try:
WHERE client = [[variable]]
or
WHERE client = '${variable:raw}'
I recommend Grafana 5.3+ (available as a nightly dev build at the moment), where PostgreSQL query editor is improved - you can see there Generated SQL, so you will spot added quotes in your case: