# Line break Mysql query

**URL:** <https://discourse.nodered.org/t/line-break-mysql-query/92554>\
**Category:** General\
**Created:** [21 October 2024 14:30 UTC](https://discourse.nodered.org/t/line-break-mysql-query/92554 "2024-10-21T14:30:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [21 October 2024 14:30 UTC](https://discourse.nodered.org/t/line-break-mysql-query/92554/1 "2024-10-21T14:30:08Z")

</div>

Is there a way to line break the sql query for the node-red-node-mysql node.  
The mysql query is a string that's assigned to the msg.topic. Some query 's are that long that you get lost in the editor screen.  
For now I break up the string with `"+"` , but that's also not ideal and sensitive to errors.

Somebody a better idea?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [21 October 2024 14:55 UTC](https://discourse.nodered.org/t/line-break-mysql-query/92554/2 "2024-10-21T14:55:42Z")

</div>

If it helps...  
For my lenghly insert-queries I use a UI-template node connected to the mysql node.  
Make sure to set the property as... msg.topic

 ![monday_MySQL_B](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20888276d14928f9f6c5740b89797506d75edef9.png)

 ![monday_MySQL_A](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cdcd81ad6f0e68afb8be00780e8531080bec9492.png)

```auto
INSERT INTO node_summary (uniqueID, date, time, deviceID, nodeID, location, deviceType, power_source, input_voltage, regulated_voltage, temperature, humidity, pressure, co2, python_script, oled_contents) VALUES (
'{{uniqueID}}',
'{{date}}',
'{{time}}',
'{{deviceID}}',
'{{nodeID}}',
'{{location}}',
'{{deviceType}}',
'{{power_source}}',
'{{input_voltage}}',
'{{regulated_voltage}}',
'{{temperature}}',
'{{humidity}}',
'{{pressure}}',
'{{co2}}',
'{{python_script}}',
'{{oled_contents}}'
)

ON DUPLICATE KEY UPDATE
uniqueID='{{uniqueID}}',
date='{{date}}',
time='{{time}}',
deviceID='{{deviceID}}',
nodeID='{{nodeID}}',
location='{{location}}',
deviceType='{{deviceType}}',
power_source='{{power_source}}',
input_voltage='{{input_voltage}}',
regulated_voltage='{{regulated_voltage}}',
temperature='{{temperature}}',
humidity='{{humidity}}',
pressure='{{pressure}}',
co2='{{co2}}',
python_script='{{python_script}}',
oled_contents='{{oled_contents}}'

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 October 2024 16:28 UTC](https://discourse.nodered.org/t/line-break-mysql-query/92554/3 "2024-10-21T16:28:27Z")

</div>

> [@edje11](#):
>
> Somebody a better idea?

Depends what part of the query.

If you are talking about the values, then yes. Do NOT generate SQL inserts or updates (or any kind) using strings (they are at risk of SQL Injection hacks / bad practice). Instead, use parameters (prepared queries).

It is detailed on the [README](https://flows.nodered.org/node/node-red-node-mysql) and there are tonnes of examples in the forum.

---

<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:** [4 November 2024 16:28 UTC](https://discourse.nodered.org/t/line-break-mysql-query/92554/4 "2024-11-04T16:28:31Z")

</div>

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