Hi, I want to write data to a table, they are written, but if I try to write again, it creates a duplicate. Actually the question: I just need to output to a separate variable so that they are not created? Here is my code:
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "root", password: "", database: "steam_bot" }); function RecordUsers() { console.log("Соединение установлено!"); var sql = "UPDATE `users` SET name ='Test' WHERE steamid = '"+steamID+"'"; con.query(sql, function (err, rows, result) { if (err) throw err; console.log("1 record update"); if (rows[0] < 1) { var sql = "INSERT INTO `users`(name, steamid) VALUES ('Testovino','"+steamID+"')"; con.query(sql, function (err, result) { console.log("1 record insert"); }); } }); } Google, everywhere Pyha ..
row[0]when you run anupdaterequest? it does not return a data set. It may, of course, be the number of affected lines, but I doubt something. - teraninsert ... on duplicate key update ..- teran