# Error: ER\_EMPTY\_QUERY: Query was empty

**URL:** <https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831>\
**Category:** General\
**Created:** [4 June 2019 09:20 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831 "2019-06-04T09:20:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [4 June 2019 09:20 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/1 "2019-06-04T09:20:54Z")

</div>

Hi, I'm trying to learn node-red and taking things one step at a time. I'm currently trying to store multiple sensor data to a mysql db with no luck. So, i tried to break it down by using an inject node, mysql node and a debug node. The mysql node shows connected to my local mysql server but when i click on the inject node i keep getting this error:  
"Error: ER\_EMPTY\_QUERY: Query was empty"

My inject payload is set to string with the value:  
INSERT INTO results (ldr) VALUES (20);

I'm simply trying to prove that i can insert the data decimal '20' into table 'results', column 'ldr'. When i run this same INSERT command in PHP on the same machine to the same DB, it works fine. I've tried adding quotation marks, apostrophes and every other combination with no luck. There is not much info on the web that i can find to help me and its getting quite frustration.

Help would be most welcome...kind regards...

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 June 2019 09:26 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/2 "2019-06-04T09:26:07Z")

</div>

Take a look at the info panel of the SQL node you are using ( its always useful if you specify which node you are using)

Assuming you are using node-red-node-mysql, the query isn't in msg.payload...

---

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [4 June 2019 09:30 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/3 "2019-06-04T09:30:46Z")

</div>

Hi, Sorry yes, I'm using what you have suggested. Yes, its in msg.payload with string (az)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 June 2019 09:32 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/4 "2019-06-04T09:32:27Z")

</div>

So if you read the info panel as I suggested you will see

> The `msg.topic` must hold the _query_ for the database, and the result is returned in `msg.payload` .

Those info panels are useful...

---

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [4 June 2019 09:38 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/5 "2019-06-04T09:38:13Z")

</div>

Hi, thanks for your replies but im still unsure. I learn best from following examples and thats what i was working from for this db test, which was obviously wrong!. Do you know of any mysql inject examples that I can look at??. kind regards...

---

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [4 June 2019 09:40 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/6 "2019-06-04T09:40:50Z")

</div>

msg.topic "INSERT INTO results (ldr) VALUES (20);"

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 June 2019 09:41 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/7 "2019-06-04T09:41:50Z")

</div>

Have you tried searching the flows library?

[https://flows.nodered.org/?term=mysql&type=flow&num\_pages=1](https://flows.nodered.org/?term=mysql&type=flow&num_pages=1)

---

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [4 June 2019 09:51 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/8 "2019-06-04T09:51:52Z")

</div>

Bingo... got it working by following the example flow:  
'Log MQTT to MySQL'  
That's all I needed to get me going.  
Your help was invaluable...many thanks. Don...

---

<div class="post-metadata">

**Author:** ![himharsh1997](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@himharsh1997](https://discourse.nodered.org/u/himharsh1997)\
**Post date:** [3 March 2020 15:50 UTC](https://discourse.nodered.org/t/error-er-empty-query-query-was-empty/11831/9 "2020-03-03T15:50:02Z")

</div>

This may due to not providing query or some reference error.
