MySQL Node Query Parameters with commas

Describe the problem/error/question

I’m using the MySQL node Execute Query function, and am entering a list of about 20 parameters. Some of the parameter values are text, and some of those text fields have commas in them.

What is the error message (if any)?

That screws up the parameters. If the text in the query parameters field is
{{ $json.field1 }},{{ $json.field2 }},{{ $json.field3 }}

and

field1 is "Lee"
field2 is "New York, NY"
field3 is 10011

Then my insert statement of
INSERT (Name, CityState, Zip) VALUES ($1, $2, $3)
evaluates to
INSERT (Name, CityState, Zip) VALUES ('Lee', 'New York','NY', 10011)

I tried setting the list to
'{{ $json.field1 }}','{{ $json.field2 }}',{{ $json.field3 }}
but the quotes ended up as part of the input string.

Please share your workflow

It’s too long and complicated, but if you really need it I’ll include it.

Information on your n8n setup

  • Version: 0.236.1
  • Database: MySQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I forget
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm / pm2
  • Operating system: ubuntu

Hi @Lee_S, I am so sorry you’re having trouble.

Can you try sending these parameters as a true JS array? Like {{ [$json.field1, $json.field2, $json.field3] }}, similar to what I’ve shown over here for Postgres?

Please do let me know if you’re still having trouble getting text values with commas to work afterwards.

I will try that the next time I reconfigure the node. For now, the below seems to be working.

The example I posted was simplified for clarity. The actual query has a lot more columns. The “title” column sometimes has a comma or apostrophe in the text.

1 Like

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