Query - Adding a suffix to a variable?


I hope you can give a little help to a newbie.

This query works.

SELECT “value” FROM “mcsMQTT” WHERE (“device”::tag = ‘1st_Living Room_VStat-1-Current Temperature’) AND $timeFilter

I would like to change 1st_Living Room_VStat-1- with a variable, but leaving Current temperature in place.

I have defined a custom variable vstats:
Vstat 1 - 1st Living Room : 1st_Living Room_VStat-1-

But don’t find a way to successfully include this variable inside a query.

I tried this query but it does not work:

SELECT “value” FROM “mcsMQTT” WHERE (“device”::tag =~ /^$vstats$/‘Current Temperature’) AND $timeFilter

It’s because of my poor query-building knowledge. I hope anyone can help me structure the query correctly.

Thank you

Found it.

SELECT “value” FROM “mcsMQTT” WHERE (“device” =~ /^$vstats$*Current Temperature/) AND $timeFilter


1 Like