You can’t, but you can use ES6 template strings instead. The following would have worked too:
msg.topic = `SELECT * FROM \`NodeRed\`.\`7bchannels\` WHERE channel= ${msg.payload}`;
return msg;
Since template strings use backticks as surrounding quotes, you need to escape the backticks inside the string. To reference variables inside, you use the ${var} syntax.
If those backticks inside the query are optional which I don’t know/want to know (I can no longer do SQL, PTSD; it’s a long story), you could also leave them out as in @bakman2’s answer.
Thank you @dynamicdave I will give it a try as well.
The issue is that the whole plan is in my head but as I am trying to understand javascript and the meanings of all these msg.options, msg.paylad,... it is a matter of keeping things as simple as possible.
Still trying to find the best way to learn all these things, specially writing functions. Like the "learn javascript for node-red" manual would be good. For now I learn most via this forum.
For those using mariaDB I've create a 'select' function that works with msg.payload.
```var t = "SELECT DateAndTime, Temperature, Humidity, BarrPress FROM temp-at-interrupt where minute(Time)= '00' order by DateAndTime DESC LIMIT " + msg.payload
return {topic:t} ```
I'm injecting a numberic payload of 22 (record count)
Eventually, I'll add a slide node to make my select statement dynamic.
Thank you "dynamicdave" for you great post.
Also, in general, this site is my favorite help site for everything "node-red" and R-Pi.