# Combine Data / Array

**URL:** <https://discourse.nodered.org/t/combine-data-array/12449>\
**Category:** General\
**Created:** [21 June 2019 08:15 UTC](https://discourse.nodered.org/t/combine-data-array/12449 "2019-06-21T08:15:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [21 June 2019 08:15 UTC](https://discourse.nodered.org/t/combine-data-array/12449/1 "2019-06-21T08:15:23Z")

</div>

Hi, everyone. I have a problems about the join node.

Example : When I interval the timestamp, all the node will run. Their will display 26 data.

 ![image.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/596f3f29e3d8eddcfbabfa00e467a90ea8fbdca5.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3281b59c0c7450dccfc89c339b8032a3c08a9a54.png)

But now the problems is sometime the join node get the duplicated data. (Example : 2 main\_fail).

If I dont want using join node, How to write a function combine all the array or data?

TQVM.

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [21 June 2019 10:05 UTC](https://discourse.nodered.org/t/combine-data-array/12449/2 "2019-06-21T10:05:03Z")

</div>

The following picture is main\_fail function(active) and main\_fail(off).

 ![image.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/699bc930ce16de486698791389bae54749fcf000.png)

 ![image.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/cf1ce26632aa5d98956e5b78053d14b011ff2cbe.png)

msg.main\_fail[0] is I get the data from database. Then the IntData check is 1 or 0 if it is one the run the msg.payload else return null. So my join node got 26 data or array.

If got any suggestion I will try.

TQVM

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [21 June 2019 10:10 UTC](https://discourse.nodered.org/t/combine-data-array/12449/3 "2019-06-21T10:10:27Z")

</div>

What are the database nodes you are using? Have you tried optimising those, to reduce the number different searches?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 June 2019 10:46 UTC](https://discourse.nodered.org/t/combine-data-array/12449/4 "2019-06-21T10:46:51Z")

</div>

If you are using the `join` node to manually join the messages, each message needs to have msg.parts defined as it explainse in the node's info tab. If you assign each msg to be joined a unique msg.parts.index, then the join node will wait for all 26 parts to show up.

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 June 2019 02:20 UTC](https://discourse.nodered.org/t/combine-data-array/12449/5 "2019-06-24T02:20:20Z")

</div>

I'm using MSSQL.  
This is the main\_fail active.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3453df71cd424946a9326a68aef6968e13c162b9.png)

This is the main\_fail off.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/65fa2b63f3850688870f69c097a4d121a31f3eae.png)

I need to check the database weather is 1 or 0.  
Maybe I try to optimize it.  
Thanks.

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 June 2019 02:39 UTC](https://discourse.nodered.org/t/combine-data-array/12449/6 "2019-06-24T02:39:22Z")

</div>

How to define every msg.parts? Sorry I not very expert using node-RED.

After using Join node I put all the payload inside the function node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a9e0e3421d872d4a400a18849291c8776a600641.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 June 2019 03:00 UTC](https://discourse.nodered.org/t/combine-data-array/12449/7 "2019-06-24T03:00:40Z")

</div>

This is my problems. Sorry for broken english.  
Example:

Step 1: In the groov view I key in all is “0” mean they just send the Off node to the website.  
Step 2 : I key in **main\_fail** and **upsensor\_fail** become “1”, they just send the **main\_fail** (active), **upsensor\_fail** (active) other send the off node.  
Step 3 : I key in the **upsensor\_fail** become “0”, they just send the **main\_fail** (active) other send the off node.  
until step 3 don’t have problems when I continue with step 4…  
Step 4 : I key in the **main\_fail** become “0”, sometime I can get the **main\_fail** “0” sometime I get multiple **s\_estop**.

![image](https://sea2.discourse-cdn.com/flex016/images/transparent.png)

Thanks.
