Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
¿Cómo actualizar varias columnas con una consulta?

Estoy tratando de actualizar varias columnas de una tabla siguiendo un mensaje de consulta. Recibo un error después de la instrucción db.query. Aquí está mi código:

 function updateEmpRole() { db.query( 'SELECT * FROM role', function(err, results) { const role = results.map(role => { return {name: role.title, value: role.id} }); if (err) throw err; db.query( 'SELECT * FROM employee', function(err, results) { const employee = results.map(employee => { return {name: employee.first_name+' '+employee.last_name, value: employee.id} }); if (err) throw err; db.query( 'SELECT * FROM employee WHERE manager_id IS NULL', function(err, results) { const manager = results.map(manager => { return {name: manager.first_name+' '+manager.last_name, value: manager.id} }); if (err) throw err; inquirer.prompt([ { type: 'list', name: 'id', message: 'Select an employee to update:', choices: employee }, { type: 'list', name: 'role_id', message: 'Please assign a new role:', choices: role }, { type: 'list', name: 'manager_id', message: 'Please assign a manager:', choices: manager } ]) .then((response) => { db.query( `UPDATE employee SET role_id = ?, manager_id = ? WHERE id = ?`, response, function(err, results) { console.table('Employee successfully updated.'); if (err) throw err; startApp(); }) }) })})})};

¿Cómo debo especificar correctamente SET? Solo quiero actualizar role_id y manager_id.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!