# Update SQL Table of multiple rows with different identifiers

**URL:** <https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632>\
**Category:** Share Your Projects\
**Created:** [19 August 2022 03:11 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632 "2022-08-19T03:11:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kimo](https://discourse.nodered.org/u/Kimo)\
**Post date:** [19 August 2022 03:11 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632/1 "2022-08-19T03:11:41Z")

</div>

Hi. I been stuck for some days figuring out how I can update multiple rows of a sql table which have different identifier. Inside my flow, when user key in an input, the data will send to sql table also to a ui table the same time as shown below with red area. Then, user will press start to log the start timestamp and update the timestamp into sql table. However, if user can submit data multiple times bfore pressing start, how I can update these data with same timestamp?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/002fac2fa0c3b036ab5d3b9d0460cc1a064b5632.png)

Here attach also the flow for reference. Thank you for the help.  
[example.json](https://discourse.nodered.org/uploads/short-url/k8yPmVpnAThxTCaOKHjR56qF3N4.json) (19.9 KB)

---

<div class="post-metadata">

**Author:** ![Kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kimo](https://discourse.nodered.org/u/Kimo)\
**Post date:** [19 August 2022 04:31 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632/2 "2022-08-19T04:31:20Z")

</div>

Or maybe anyone here know how to update sql table if the id is in array?

---

<div class="post-metadata">

**Author:** ![karlbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/karlbo/32/68793_2.png) [@karlbo](https://discourse.nodered.org/u/karlbo)\
**Post date:** [6 October 2022 23:02 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632/3 "2022-10-06T23:02:37Z")

</div>

could you show what comes from the join msg and the insert into DB?  
not knowing what it says there, its impossible to be of any help to you.

---

<div class="post-metadata">

**Author:** ![Kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kimo](https://discourse.nodered.org/u/Kimo)\
**Post date:** [9 October 2022 06:30 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632/4 "2022-10-09T06:30:57Z")

</div>

Nevermind. Thank you for replying. I have managed to solve this. Everyone have same application can refer to this post below. Thank you

> [@How to update SQL query with an identifier has 2 strings](https://discourse.nodered.org/t/how-to-update-sql-query-with-an-identifier-has-2-strings/66647/6):
>
> that is not what I said to do... e.g.. const array = flow.get('array'); //example ["A1", "A2"]; if(!array || !array.length) { node.warn("array is empty"); return null // halt flow } const whereClause = "(" + array.map(e =\> "'" + e + "'").join(",") + ");" const now = new Date().toLocaleString("en-GB"); msg.payload = "UPDATE [dbo].[Background] SET [Start\_Time] = '" + now + "' WHERE [Name] in " + whereClause; return msg;

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 October 2022 06:31 UTC](https://discourse.nodered.org/t/update-sql-table-of-multiple-rows-with-different-identifiers/66632/5 "2022-10-23T06:31:38Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
