Is it possible to use variables as parts of the query?
Somewhat like this:
SELECT UNIX_TIMESTAMP(time) as time_sec, sample_value as value
FROM SOMETHING + VARIABLE_HERE+ SOMETHING ELSE
WHERE adb.patients_patient_id
= $pid
Is it possible to use variables as parts of the query?
Somewhat like this:
SELECT UNIX_TIMESTAMP(time) as time_sec, sample_value as value
FROM SOMETHING + VARIABLE_HERE+ SOMETHING ELSE
WHERE adb.patients_patient_id
= $pid
Yes it is possible, from the documentation. In the section "Using Variables in Queries" they show how to use variables inside of a MySQL query from Grafana. $hostname here is the variable:
SELECT
UNIX_TIMESTAMP(atimestamp) as time,
aint as value,
avarchar as metric
FROM my_table
WHERE $__timeFilter(atimestamp) and hostname in($hostname)
ORDER BY atimestamp ASC