Korenron
Korenron

Reputation: 101

MySQL - copy data from row to another table?

I have a table1 and table2 I want to update the address in table2 according to the name in table1

for example :

table 1 (the curent update data)

jhonny 1st street david 2nd street danny 4th street

table 2 (old):

jhonny unknown

david 5th street

danny france

daniel 2nd street

table2 (need to be as table1)

jhonny 1st street

david 2nd street

danny 4th street

daniel 2nd street

is there a command that do it automateclly ? or I need to write a code for it?

Thanks ,

Upvotes: 0

Views: 18

Answers (1)

Dylan Fouche
Dylan Fouche

Reputation: 91

Try this:

UPDATE Table1, Table2
SET Table2.address = Table1.address
WHERE Table1.Name = Table2.Name

Upvotes: 0

Related Questions