Modify several tables with a join

1

Currently in my project I own 5 tables that are related to each other through a series of primary and foreign keys. Now I have a section where I can modify the data of all the tables but I would like to do it with an inner join. Is this possible? Or should I do it table by table respecting your foreign codes?

    
asked by shadowmors 29.12.2016 в 05:25
source

1 answer

0

Yes, multiple tables can be updated, as specified in UPDATE .

Example:

UPDATE Tabla_A a 
 INNER JOIN Tabla_B b 
    ON (a.id = b.id) 
   SET 
       a.campo = 4321, 
       a.ediciones = a.ediciones+1, 
       a.autor = "Nombre", 
       b.texto = "xyz",
       b.votos = 9
 WHERE a.id = 1;
    
answered by 29.12.2016 в 06:37