tags:

views:

86

answers:

1

Having trouble figuring out the syntax for this one... :-/

Table 1

ID  FEE   FAI   FOE
0   Fee1  Fai1  Foe1
1   Fee2  Fai2  Foe2
2   Fee3  Fai3  Foe3

Table 2

ID  FEE   FAI   FUM
 -  Fee1  Fai1  Fum1
 -  Fee2  Fai2  Fum2
 -  Fee3  Fai3  Fum3

Based on the shared columns FEE and FAI, which when combined form unique pairs, I'd like to copy the appropriate ID values from table 1 to table 2. Not all data in table 1 is present in table 2 and vice versa, so the IDs have to be matched to their correct rows.

I know this requires an UPDATE SET and possibly a JOIN, but am having trouble coming up with anything that phpMyAdmin is willing to chew on, and having trouble finding a sufficiently related question on SO that can get me moving.

Sorry for such an easy one, and thank you for your time.

+1  A: 
update table2
  join table1
    on (table1.FEE, table1.FAI) = (table2.FEE, table2.FAI)
   set table2.id = table1.id
longneck