Update a MYSQL DB Entry

Hey, again a noob question ^^
i tried 2 put something into my sql DB and it worked

function:
var frisch = msg.count;
query = INSERT INTO Wasser(Stand) VALUES("+frisch+");;
msg.topic = query;
return msg;

but now i want, that he updates "Stand" with every new entry....

var frisch = msg.count;
query = UPDATE Wasser(Stand) VALUES("+frisch+") WHERE 1;;
msg.topic = query;
return msg;

this was my try, but it didnt worked... maybe my DB has the wrong settings or something. Can someone help me and explain the mistake i am doing? thanks! :slight_smile:

The variable query value you are settng is supposed to be a string so is missing quotes around it. E.g...

var query = 'INSERT INTO Wasser(Stand) VALUES("' + frisch + '");';

There is some useful info on SQL here:

SQL UPDATE Statement (w3schools.com)

and here:

MySQL :: MySQL 8.0 Reference Manual :: 13.2.13 UPDATE Statement

Your update command isn't quite right but you are close.

Don't forget that if you want to update a record, you have to select the right row with the WHERE part. How you construct the WHERE is dependent on what fields (columns) you have in the db table.

You will probably want a tool that gives you a user interface to your MySQL db.