Prevent MySQL row being updated twice at once? (nodejs mysql)

I have this code in my server node__s file to update a row in mysql db using a mysql module using socket.io that is updated every second:

var query_update = mysql.query('UPDATE `auctions` \
SET `random` = ?,`price`= ?,`datetime` = ? WHERE `id` = ?', \
[rand, price, t, auction.id]);  
console.log('\n'+time()+query_update.sql+'\n'); 

      

I don't know why, but some specific line entries will update twice at a time. Is there a way to prevent this? Maybe even mysql-wise that a row can be updated every x seconds once?

I also used milliseconds as the output of console.log (during the () function) to figure out if this happens a few milliseconds after the first update, but it happens at the same moment:

enter image description here

Other auctions just update once and I can't figure out why.

+3


source to share


1 answer


My problem was that I was SELECT

editing data and not using GROUP BY

and I used LEFT JOIN

in the previous SELECT

-statement. So he fetched the same row twice.



0


source







All Articles