function updateEmployeeRole() {
  connection.query("SELECT last_name FROM employee", function (err, res) {
    console.log(res)

    var employee_last_name = []
    for (var i = 0; i < res.length; i++) {
      employee_last_name.push(res[i].last_name)
    }

    connection.query("SELECT title FROM employee_role", function (err, res) {

      var employee_title = []
      for (var i = 0; i < res.length; i++) {
        employee_title.push(res[i].title)
      }

      inquirer.prompt([
        {
          name: "last_name",
          type: "list",
          message: "Enter the last name of the employee you want to update",
          choices: employee_last_name

        },
        {
          name: "new_role",
          type: "list",
          message: "What new role would you like to give this employee?",
          choices: employee_title
        }

      ])
        .then(function (answer) {

          connection.query("SELECT id FROM employee_role WHERE title = ?",
            [answer.new_role],

            function (err, res) {
              console.log('ID of selected employee_role', res, res[0].id, answer.last_name)
              if (err) throw err;
              connection.query("UPDATE employee SET ? WHERE ?",
              [
                {
                  role_id: res[0].id
                },
                {
                  last_name: answer.last_name
                }
              ], function (error, res) {
                  if (error){
                    console.log('AHHHHH', error)
                    throw err;
                  }
                  start();
                }
              )
            }
          )
        })
    })
  })
}
// prompt for info about the new department
prompt for info about the new department
prompt for info about the new department
function updateEmployeeRole() {
  connection.query("SELECT last_name FROM employee", function (err, res) {
    console.log(res)
    var employee_last_name = []
    for (var i = 0; i < res.length; i++) {
      employee_last_name.push(res[i].last_name)
    }
    connection.query("SELECT title FROM employee_role", function (err, res) {
      var employee_title = []
      for (var i = 0; i < res.length; i++) {
        employee_title.push(res[i].title)
      }
      inquirer.prompt([
        {
          name: "last_name",
          type: "list",
          message: "Enter the last name of the employee you want to update",
          choices: employee_last_name
        },
        {
          name: "new_role",
          type: "list",
          message: "What new role would you like to give this employee?",
          choices: employee_title
        }
      ])
        .then(function (answer) {
          connection.query("SELECT id FROM employee_role WHERE title = ?",
            [answer.new_role],
            function (err, res) {
              console.log('ID of selected employee_role', res, res[0].id, answer.last_name)
              if (err) throw err;
              connection.query("UPDATE employee SET ? WHERE ?",
              [
                {
                  role_id: res[0].id
                },
                {
                  last_name: answer.last_name
                }
              ], function (error, res) {
                  if (error){
                    console.log('AHHHHH', error)
                    throw err;
                  }
                  start();
                }
              )
            }
          )
        })
    })
  })
}
function updateEmployeeRole ( ) { connection . query ( "SELECT last_name FROM employee" , function ( err , res ) { console . log ( res ) var employee_last_name = [ ] for ( var i = 0 ; i < res . length ; i ++ ) { employee_last_name . push ( res [ i ] . last_name ) } connection . query ( "SELECT title FROM employee_role" , function ( err , res ) { var employee_title = [ ] for ( var i = 0 ; i < res . length ; i ++ ) { employee_title . push ( res [ i ] . title ) } inquirer . prompt ( [ { name : "last_name" , type : "list" , message : "Enter the last name of the employee you want to update" , choices : employee_last_name } , { name : "new_role" , type : "list" , message : "What new role would you like to give this employee?" , choices : employee_title } ] ) . then ( function ( answer ) { connection . query ( "SELECT id FROM employee_role WHERE title = ?" , [ answer . new_role ] , function ( err , res ) { console . log ( 'ID of selected employee_role' , res , res [ 0 ] . id , answer . last_name ) if ( err ) throw err ; connection . query ( "UPDATE employee SET ? WHERE ?" , [ { role_id : res [ 0 ] . id } , { last_name : answer . last_name } ] , function ( error , res ) { if ( error ) { console . log ( 'AHHHHH' , error ) throw err ; } start ( ) ; } ) } ) } ) } ) } ) }
prompt for info about the new department
prompt for info about the new department