# Inserting a record in MySQL from a payload: Null values are being inserted in fields

**URL:** <https://discourse.nodered.org/t/inserting-a-record-in-mysql-from-a-payload-null-values-are-being-inserted-in-fields/46340>\
**Category:** General\
**Created:** [27 May 2021 12:45 UTC](https://discourse.nodered.org/t/inserting-a-record-in-mysql-from-a-payload-null-values-are-being-inserted-in-fields/46340 "2021-05-27T12:45:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shnkar007](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@shnkar007](https://discourse.nodered.org/u/shnkar007)\
**Post date:** [27 May 2021 12:45 UTC](https://discourse.nodered.org/t/inserting-a-record-in-mysql-from-a-payload-null-values-are-being-inserted-in-fields/46340/1 "2021-05-27T12:45:27Z")

</div>

Hi  
I'm new to NodeRed. I am trying to insert a row in mysql table in a nodered function. In the inject node I have specified the values of each field and added to msg.payload. In the function node, I'm creating an Insert query and passing each field in the insert query.  
When I run the flow, the row is created in the table without values in the fields. Any tutorial on the right way of doing it?

---

<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:** [27 May 2021 12:59 UTC](https://discourse.nodered.org/t/inserting-a-record-in-mysql-from-a-payload-null-values-are-being-inserted-in-fields/46340/2 "2021-05-27T12:59:44Z")

</div>

Put a `debug` (set to display the complete msg object) on the output of the `function` node and run an insert. Then open add the arrows in the debug output and paste it into a reply.

---

<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:** [26 July 2021 13:00 UTC](https://discourse.nodered.org/t/inserting-a-record-in-mysql-from-a-payload-null-values-are-being-inserted-in-fields/46340/3 "2021-07-26T13:00:19Z")

</div>

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