Query mysql in phpmyadmin

Asked

Viewed 33 times

1

Good afternoon guys, can someone please help me?

I have two tables, Tabela1 and Tabela2, would like to enter the column data carro of Tabela2 in the column carro of Tabela1, but in their respective id’s, like, the column tabela2_id of Tabela1 is the primary key to Tabela2.

tabela1_tabela2

1 answer

1


See if that 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 as an example 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
  • The original query is this UPDATE t1 SET t1.carro = t2.carro_id FROM tp531710 as t1 INNER JOIN journey as t2 on t2.id = t1.jornada_id

  • Presented this error #1064 - You have a syntax error in your SQL next to 'FROM tp531710 as t1 INNER JOIN journey as t2 on t2.id = t1.jornada_id' on line 3

  • See if now resolves, I edited my answer with another way

  • Fantastic!!!! It worked, thank you !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.