5

Using mysql end nodejs , how can I get the entire updated rows ?

var query2 = connection.query('UPDATE campaigns SET USED=0 where amount=?' , [amount], function (error, results, fields) {
                console.log(query2.sql);
                if (error) throw error;

// Get here all updated rows

}

With affectedRows, I can get only the number of updated rows.

dt dino
  • 1,194
  • 6
  • 19

1 Answers1

0

you can select all row's ids before update, then update them and then select them by ids

1st step: select id from campaigns where amount=?

2nd step: update campaigns set USED=0 where amount=?

3d step: select * from campaigns where id in (<ids from 1st step>)