Query mysql in phpmyadmin

1

Good afternoon guys, can anyone help me please?

I have two tables, Tabela1 and Tabela2 , I would like to insert data from column carro of Tabela2 into column carro of Tabela1 , but in their respective id's, type, column tabela2_id of Tabela1 is the primary key of Tabela2 .

    
asked by anonymous 25.10.2018 / 19:02

1 answer

1

See if this solves your problem

update t1
   set t1.carro = t2.carro
  from tabela1 as t1
 inner join tabela2 as t2 on t2.id = t1.tabela2_id

I used this answer

EDITED

UPDATE tp531710 t1 INNER JOIN jornada as t2 on t2.id = t1.jornada_id
    SET t1.carro = t2.carro_id
  WHERE t1.carro is null
    
25.10.2018 / 19:14