There are two table, qr_manager_qrcode
and qr_manager_qrcategory
. The columns of the qr_manager_qrcode
table are
- id
- category_id
- created
and the columns of qr_manager_qrcategory
are
- id
- name
I want to render a time-series graph of the count of qr_manager_qrcode
records group by the qr_manager_qrcategory
and display qr_manager_qrcategory.name
with the usage count for the selected time range of qr_manager_qrcode.created
Here is the SQL query working fine in the MySQL workbench
SELECT
qr_manager_qrcode.created AS "time",
qr_manager_qrcategory.name AS "name",
count(*) as 'usage'
FROM qr_manager_qrcode
WHERE
$__timeFilter(qr_manager_qrcode.created)
inner join qr_manager_qrcategory on qr_manager_qrcategory.id = qr_manager_qrcode.category_id
GROUP BY qr_manager_qrcode.category_id
ORDER BY qr_manager_qrcode.created
But in Grafana, it is giving an error
Error 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 'inner join qr_manager_qrcategory on qr_manager_qrcategory.id = qr_manager_qrcode' at line 8