I have a table called UserRequests. I need to update the RequestStatus to Completed, Time to current DateTime for a a couple of request records. I am using the node.js mysql module https://github.com/mysqljs/mysql
Usually for a single record update I would do:
connection.query('update UserRequests set RequestStatus = ?, ReqCompletedDateTime = ? where idRequest = ?', ['Completed', new Date(), hReqId], function(err, rows){
connection.release();
});
But in my case I need to update multiple UserRequests rows with the status of completed and current datetime.
I am getting all the updated request ids in a list. The question is how do I write the query statement that it will update all of them together.
I tried using the multiple query statement but it did not work. Couple of other solutions also did not work. Few othe solutions I tried :
connection.query('update UserRequests set RequestStatus = ?, ReqCompletedDateTime = ? where idRequest = ?', [['Completed', new Date(), 'somerowid1'], ['Completed', new Date(), 'somerowid2']], function(err, rows){
connection.release();
});
OR
connection.query('update UserRequests set RequestStatus = ?, ReqCompletedDateTime = ? where idRequest = ?', [{'Completed', new Date(), 'somerowid1'}, {'Completed', new Date(), 'somerowid2'}], function(err, rows){
connection.release();
});
What am I doing wrong?
via codeinprogress
No comments:
Post a Comment