Update two records of a table without having the ID

0

I have a table that I want to update, where I am relating the PKs of three tables:

  • Work
  • teacher
  • rollprof
  • The table I want to update is structured in this way:

    CREATE TABLE IF NOT EXISTS 'sgtegcom'.'docente_has_rollprof' (
    'idd' INT NOT NULL AUTO_INCREMENT,
    'docente_iddo' INT NOT NULL,
    'rollprof_idroll' INT NOT NULL,
    'trabajo_id' INT NOT NULL,
     PRIMARY KEY ('idd', 'docente_iddo', 'rollprof_idroll', 'trabajo_id'),
    INDEX 'fk_docente_has_rollprof_rollprof1_idx' ('rollprof_idroll' ASC),
    INDEX 'fk_docente_has_rollprof_docente1_idx' ('docente_iddo' ASC),
    INDEX 'fk_docente_has_rollprof_trabajo1_idx' ('trabajo_id' ASC),
    CONSTRAINT 'fk_docente_has_rollprof_docente1'
    FOREIGN KEY ('docente_iddo')
    REFERENCES 'sgtegcom'.'docente' ('iddo')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
    CONSTRAINT 'fk_docente_has_rollprof_rollprof1'
    FOREIGN KEY ('rollprof_idroll')
    REFERENCES 'sgtegcom'.'rollprof' ('idroll')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
    CONSTRAINT 'fk_docente_has_rollprof_trabajo1'
    FOREIGN KEY ('trabajo_id')
    REFERENCES 'sgtegcom'.'trabajo' ('id')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
    ENGINE = InnoDB
    

    In this table, the roll of the teacher is assigned according to its function:

    id_roll = 1(jurado principal)
    id_roll = 2(jurado suplente)
    id_roll = 3(tutor)
    

    Now, how can I do to update the table when I have two different teachers with the id_roll to 1 ? (to give an example).

    I put the PHP code that I have so far:

    <?php
    if (isset($editar))
    {
    $DT ="UPDATE 'trabajo' SET'nombretrabajo'='$tituloteg','mencion_idm'='$mencion','nucleo_idn'='$nucleo','consejo_idcon'='$cnucleo' 
    WHERE id = '$id' ";
    mysqli_query ($conexion, $DT);
    
    $tutor ="UPDATE 'docente_has_rollprof' SET 'docente_iddo'='$stutor' WHERE 
    rollprof_idroll = '3' and trabajo_id ='$id'";
    mysqli_query ($conexion, $tutor);
    if($conexion->connect_errno)
    {
        echo "2";
    }
    else
    {
        echo "1";
    }    
    }
    

    P.D: with the tutor there is no problem, because it is a single record as seen before.

        
    asked by Braian Jaimes 27.08.2018 в 01:09
    source

    0 answers