# "Error: You have an error in your SQL syntax;

**URL:** <https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821>\
**Category:** General\
**Created:** [7 December 2022 14:19 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821 "2022-12-07T14:19:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ODB](https://avatars.discourse-cdn.com/v4/letter/o/eb9ed0/32.png) [@ODB](https://discourse.nodered.org/u/ODB)\
**Post date:** [7 December 2022 14:19 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/1 "2022-12-07T14:19:26Z")

</div>

![write to sql](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e79a4c8eb6f656f8156f25cb8fbbe6008e435280.png)

 ![mySQL](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/9192c2a5dff2b0b3b2b1d02d2ee4751630361331.png)

Hi everyone,  
I'm learning Node-RED, i've hit a wall with this error -

"Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Timestamp','Values')VALUES('07/12/2022, 13:58:08', 13)' at line 1"

It is a very basic flow, first of all i was writing only the value to mySQL and had no problems.  
I've now added a second column called 'Timestamp' and i'm returning the error above.

Please can anyone help me with this?

---

<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:** [7 December 2022 15:23 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/2 "2022-12-07T15:23:25Z")

</div>

What version of sql are you using (MySQL, MSSQL etc)?  
What does you version define a timestamp as?  
Does the data you are inserting match the data type of what you have defined?

---

<div class="post-metadata">

**Author:** ![ODB](https://avatars.discourse-cdn.com/v4/letter/o/eb9ed0/32.png) [@ODB](https://discourse.nodered.org/u/ODB)\
**Post date:** [7 December 2022 16:03 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/3 "2022-12-07T16:03:22Z")

</div>

![flow1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c2e90a7af0899fc984a15ad8ab170945c82129b2.png)  
 ![inject node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3ff662014ca03d3a4058f43deb5ad5807fca6642.png)

I'm using mySQL.

Where it refers to 'line 1' in the error message, does that mean the issue lies within the first line of the code, i.e. value1? If so, that is very strange because i have been recording that value in a single column to test it for a few days. The issue has only appeared since adding the second column in mySQL.

---

<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:** [7 December 2022 16:43 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/4 "2022-12-07T16:43:31Z")

</div>

The `DATETIME` type is used for values that contain both date and time parts. MySQL retrieves and displays`DATETIME` values in `'YYYY-MM-DD hh:mm:ss`' format. The supported range is `'1000-01-01 00:00:00'` to `'9999-12-31 23:59:59'`

It looks like your date time is mm-did-yyyy format when it should Year first

---

<div class="post-metadata">

**Author:** ![ODB](https://avatars.discourse-cdn.com/v4/letter/o/eb9ed0/32.png) [@ODB](https://discourse.nodered.org/u/ODB)\
**Post date:** [7 December 2022 18:54 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/5 "2022-12-07T18:54:33Z")

</div>

Thanks, i have got it to work for now using VARCHAR(45).  
I'm not sure how to change the date format.

---

<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:** [7 December 2022 19:01 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/6 "2022-12-07T19:01:17Z")

</div>

If you are i control of the schema and not too much data has been added, why not use `timestamp` instead. Here is a site explaining it

> **[A Complete Guide to MySQL DATETIME Data Type](https://www.mysqltutorial.org/mysql-datetime/)**
>
> In this tutorial, you will learn about MySQL DATETIME data type and some useful functions to manipulate DATETIME values effectively.

---

<div class="post-metadata">

**Author:** ![RachelGomez161999](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@RachelGomez161999](https://discourse.nodered.org/u/RachelGomez161999)\
**Post date:** [16 December 2022 05:20 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/7 "2022-12-16T05:20:08Z")

</div>

Debugging a SQL query  
Go to the line that is failing in your SQL query.  
Check the SQL syntax on the line that is failing in your SQL query.  
Check your query logic if the query uses joins, subqueries, or CTEs.  
If you get an error message that isn't specific to your SQL query, go to Troubleshooting error messages.  
Regards,  
Rachel Gomez

---

<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:** [14 February 2023 05:20 UTC](https://discourse.nodered.org/t/error-you-have-an-error-in-your-sql-syntax/71821/8 "2023-02-14T05:20:24Z")

</div>

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