UPDATE with multiple WHERE and SELECT condition - MySql So, I have two tables ativos and colaboradores and they are linked by id_colaborador (FK) on my update page, I'm able to change the id_colaborador but instead of changing the ID I want to write the name that match to that ID but I think I need multiple WHERE conditions and SELECT, may anyone help me out? Thanks!
I have the following code to update

$sql = "UPDATE ativos  SET ativo = ?, comentario = ?, data_aquisicao = ?,
                           localizacao = ?, fabricante = ?, modelo = ?,
                           imei = ?, numero_serie = ?, ativo_sap = ?,
                           anexo_a = ?, evento = ?, data_evento = ?,
                         SELECT id_colaborador FROM colaboradores 
                               WHERE nome = ? AND WHERE id_ativo = ?";
Your query (while removing PHP code and formatting) looks like

UPDATE ativos  
SET ativo = ?, 
    comentario = ?, 
    data_aquisicao = ?, 
    localizacao = ?, 
    fabricante = ?, 
    modelo = ?, 
    imei = ?,         
    numero_serie = ?, 
    ativo_sap = ?, 
    anexo_a = ?, 
    evento = ?, 
    data_evento = ?, 
    SELECT id_colaborador 
    FROM colaboradores 
    WHERE nome = ? 
    AND WHERE id_ativo = ?


It is syntactically incorrect. Use Multiple-table UPDATE syntax. Final query must look near

UPDATE ativos a
  JOIN colaboradores c 
/* next line maybe wrong, question is not clear */
    ON a.id_ativo = c.id_colaborador 
SET a.ativo = ?, 
    a.comentario = ?, 
    a.data_aquisicao = ?, 
    a.localizacao = ?, 
    a.fabricante = ?, 
    a.modelo = ?, 
    a.imei = ?,         
    a.numero_serie = ?, 
    a.ativo_sap = ?, 
    a.anexo_a = ?, 
    a.evento = ?, 
    a.data_evento = ?
/* next line maybe wrong, question is not clear */
WHERE c.nome = ?