-->

parse array result from nodered and mysql

2020-05-03 09:57发布

问题:

How can I extract the value "Al Hidaya centre" from the mysql result below, I should generally get "Al Hidaya centre" as the result from the mysql query, however I am getting this mambo jumbo with the result as well.

i have tried the following msg.payload[3] but this only gives me

[ { "device_name": "Al Hidaya centre" } ]

mysql result in nodered mysql node:

{ "fieldCount": 0, "affectedRows": 0, "insertId": 0, "serverStatus": 10, "warningCount": 0, "message": "", "protocol41": true, "changedRows": 0 }, { "fieldCount": 0, "affectedRows": 0, "insertId": 0, "serverStatus": 10, "warningCount": 0, "message": "", "protocol41": true, "changedRows": 0 }, { "fieldCount": 0, "affectedRows": 0, "insertId": 0, "serverStatus": 10, "warningCount": 0, "message": "\u0012Statement prepared", "protocol41": true, "changedRows": 0 }, [ { "device_name": "Al Hidaya centre" } ], { "fieldCount": 0, "affectedRows": 0, "insertId": 0, "serverStatus": 2, "warningCount": 0, "message": "", "protocol41": true, "changedRows": 0 } ]

and the mysql query:

 SET @var_name =  (SELECT settings_table FROM prayertime_table where id = 1);   SET @s = concat('select device_name from ', @var_name) ;  PREPARE stmt1 FROM @s;  EXECUTE stmt1;  DEALLOCATE PREPARE stmt1;