I want to filter on date column in database. Then I want to show the sensor names that will come from here in the dropdown. (uniquely).
Here's what I can do
f1
start='2021-08-01'
end='2021-08-05'
msg.payload ="SELECT * FROM mat where date between '"+start+"' and '"+end+"';";
return msg;
f2
var newmsg = msg;
newmsg.options = [x];
var value;
for (var i = 0; i < msg.payload.length; i++) {
//canal = msg.payload[i].address;
value = msg.payload[i].sensor;
newmsg.options[i] = {};
newmsg.options[i] = value;
}
return msg;
A better way to do this...
... this will negate an SQL injection and is easier to configure and understand.
PS, this uses node-red-contrib-mssql-plus which has many improvements and bug fixes over the 3y old node-red-contrib-mssql
1 Like
rko
9 August 2021 20:39
3
You could group
everything with a SQL statement or transfer all data to Node-RED first and filter it there. I would try to do it in SQL because then you're receiving only relevant data.
do you think the data will be unique?
Yes.
That's what DISTINCT
is for.
You could also use group by
rko
9 August 2021 20:48
6
Can we see the above screenshot without your blue notes?
Is there a shortcut that I can print the number of data coming to the drop-down ?
what do you mean?
you mean a debug node to see what is going into the node?
To print the number of data in the text box
what number, from where? from the database? as an index count?
I want to count the number of data. As in the example, 8 pieces
system
Closed
24 August 2021 09:08
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.