-5

I currently have 2 tables.

table 1: old

id mod1 mod2 exp
----------------
1  280  20   1

table 2: new

id mod1 mod2 exp
----------------
1  0    0    0

And i want to fill the second table with all mod1 mod2 exp where die id is the same like in 1.

In table 1 i have some more ids as in table 2.

query tried so far.

UPDATE table1
INNER JOIN table2 ON table1.entry = table2.entry
SET table1.mod1 = table2.mod1;
zarruq
  • 2,445
  • 2
  • 10
  • 19
  • read about update ... join ... – Jens Oct 11 '17 at 14:05
  • 1
    Possible duplicate of [update one table with data from another](https://stackoverflow.com/questions/5036918/update-one-table-with-data-from-another) – Igor Oct 11 '17 at 14:06

1 Answers1

0

You are close.

The correct query is below.

UPDATE new t1
INNER JOIN old t2 ON t1.id = t2.id
SET t1.mod1 = t2.mod1
    ,t1.mod2 = t2.mod2
    ,t1.exp = t2.exp;

COMMIT;

You can check the demo here

zarruq
  • 2,445
  • 2
  • 10
  • 19