Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update multiple columns in mysql using nodejs

How to update the multiple columns in MySQL using node.js:

var query = 'UPDATE employee SET profile_name = ? WHERE id = ?';
connection.query(query,[req.name,req.id] function (error, result, rows, fields) {

but I have to update profile_name, phone,email, country, state, address at once.
How can I do that, can anyone suggest.

like image 830
klp Avatar asked Dec 05 '22 16:12

klp


1 Answers

Simply add all columns in set:

var query = 'UPDATE employee SET profile_name = ?, phone =?, .. WHERE id=?';

connection.query(query,[req.name,req.phone,...,req.id] function (error, result, rows, fields) {
like image 86
Jens Avatar answered Dec 19 '22 23:12

Jens