tags:

views:

38

answers:

1

Hey, I need to update the content of one data field in a table with the content of another field in a table every time two separate fields, one on each table, match up. I've been trying this syntax but I just can't get it to work properly without giving me an error.

UPDATE table1 SET field1 = table2.field1 FROM Table1,Table2 WHERE Table1.entry = Table2.entry

+1  A: 

update ... from is sql server's syntax. In MySQL you can just use multiple tables directly:

update
  table1 t1
  join table2 t2 on t2.field = t1.field
set
  t1.field1 = t2.matchingfield
where
  t1.whatever = t2.whatever

All is detailed on the MySQL update reference page.

Donnie