Javascript for while with mysql update when not having value
Javascript for while with mysql update when not having value
如果没有设置,我将更新数据库中的值。
我有这个代码:
items.forEach(function(item,i,arr){
mysqlConnection.query('UPDATE `SkinBank` SET `AssetID`=''' + item.assetid + ''', `Status`=''market'' WHERE `Status`=''open'' AND `Tradeoffer` = ''' + offer.id + ''' AND `SkinName` = ''' + item.market_hash_name + '''', function (err, row, fields) {});
});
当我放入两个以上具有item.assetid的"项目"时(例如:项目1具有=123123,项目2具有=987987),所有两个一无所有的项目都会获得相同的assetid值,例如123123或987987。
我怎么能做到,他给每个项目一个资产ID。
在此之前,列"AssetID"中没有
我猜您的WHERE
子句匹配的行太多了。目前还不清楚您使用的是什么库,但如果您使用node-mysql
,您可以输出回调函数中更新的行数:
connection.query('UPDATE `SkinBank` SET `AssetID`=''' + item.assetid + ''', `Status`=''market'' WHERE `Status`=''open'' AND `Tradeoffer` = ''' + offer.id + ''' AND `SkinName` = ''' + item.market_hash_name + '''', function (err, result) {
if (err) throw err;
console.log('changed ' + result.changedRows + ' rows');
})
https://github.com/felixge/node-mysql#getting-更改的行数
相关文章:
- jQuery is not loaded
- AngularJS JSON not arriving php
- $rootScope not working
- reactRedux is not defined
- jQuery document.ready not working
- Javascript/Jquery Blob not showing Chrome PDF
- ReferenceError: not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Javascript getElementsByTagName not working?
- jQuery.when()在循环中被忽略
- jQuery's trim()的前缀为not运算符
- Javascript - element.childNodes does not see an append.newch
- Bootstrap-Datepicker not selecting date when using "set
- Javascript for while with mysql update when not having value
- Javascript not working when echo'd by php
- IE11 not showing selected list when <s:optiontransfersele
- undefined is not a function when evaluating 'this.batman
- Javascript not working when 'alert; is removed
- jQuery tab plugin not opening in a new browser tab when pres
- Javascript - value of textarea not formatted when put in <