# Parse error - insert into MySQL

**URL:** <https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027>\
**Category:** General\
**Created:** [16 October 2018 08:24 UTC](https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027 "2018-10-16T08:24:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [16 October 2018 08:24 UTC](https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027/1 "2018-10-16T08:24:07Z")

</div>

Hi All, I read somewhere that the MySQL connector may not be able to process a multiple column insert into MySQL and would appreciate confirmation if that is the case.

I have an incoming string comprised of around 35 varchars and am using substr to split that in a function just before the MySQL connector.

```auto
var m = {
 topic : "INSERT INTO `node-red`.`tag_reads` ('node_id', `personal_id`) VALUES ('"; + msg.payload.substr(3, 4) + "', '" + msg.payload.substr(20, 33) + "');"
 };
return m

```

If I use just one column and one substr then all is ok, but two or more fail with a parse\_error (though the data in the error message is ok and of the correct format).

Is there a workaround, a for loop or something?

I also notice that the first substr doesn't seem to work properly (it should return the single character at position 3 in the string whereas it returns 4 characters starting at position 3).

Regards  
jaguar

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [16 October 2018 08:38 UTC](https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027/2 "2018-10-16T08:38:57Z")

</div>

Hi @jaguar

I've edited your post to properly format the code block by placing three backticks (`) on new lines before and after the code. That ensures the formatting is correct.

I don't know where you read the mysql node can't do multi-column inserts, because it isn't correct.

If you're getting a parse error, you'd normally get some clue as to what is wrong. I note you're using a mix of quotes in your column list - that could be something or it could be nothing.

As for `substr` ... it is doing exactly what it is meant to - returning 4 characters starting at position 3. If you want the characters between positions 3 and 4, you should use `substring`.

Nick

---

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [16 October 2018 08:48 UTC](https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027/3 "2018-10-16T08:48:54Z")

</div>

Thanks Nick for editing (the issues appeared when I copied in the function and I did attempt to correct them). substring solved the issue with the single character but I still get the parse error, error in syntax (either column names or data to be entered) thought he column names and data to be entered are showing correctly.

---

<div class="post-metadata">

**Author:** ![jaguar](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jaguar](https://discourse.nodered.org/u/jaguar)\
**Post date:** [16 October 2018 08:58 UTC](https://discourse.nodered.org/t/parse-error-insert-into-mysql/4027/4 "2018-10-16T08:58:04Z")

</div>

And thank you again, it was just the quotes surrounding the column names, removing them solved the issue.
