Updating a table having a common key

Last update on August 8, 2009 10:31 AM by jak58
Published by jak58

Updating a table having a common key






In the case you have two tables with a common key (in the case below it is the primary key "id"), it is possible to update a field in one of two tables (update_table) using data the second (reference_table) using a joint.

The SQL code will look like this:


UPDATE update_table, reference_table SET update_table.field = WHERE reference_table.fieldref update