I am trying to perform a request for a Grafana dashboard from my Raspberry SQL database. The goal is to look for the most recent timestamp in another table (this performs as unique-ID) and get the requested data (TimeAxis and WeightAxis) from a second table.
SELECT
(SELECT @stamp := unix_timestamp(coffeeTimestamp)
FROM CoffeeData
ORDER BY timestamp DESC LIMIT 1
),
TimeAxis,
WeightAxis
FROM ArrayLog
WHERE unix_timestamp(coffeeTimestamp) = @stamp
I tried several variation of this query. What hurdles me: I can get this query to do what I want, if I don't write "= @stamp" but "= 1614251117" (which is the result from the query in the brackets, if run separately). With "= @stamp" however, the query returns null.
Do you have any idea on how to solve this? Thanks!