« Removing autocomplete fields from Housing application | Main | NOy vs NOx vs NOz vs NO2 vs NO »
October 02, 2012
Copy data from 1 table to another
Upon getting rid of the Institution lookup field in favor of a simple text field, I wanted to migrate the existing Institutions to the new field prior to deleting the old. Here is the syntax to update a database table field with values drawn from another field in the same statement:
UPDATE drupal_content_type_housing_application
LEFT JOIN drupal_node
ON drupal_content_type_housing_application.field_housing_inst_affil_nid=drupal_node.nidSET drupal_content_type_housing_application.field_app_inst_affil_value = drupal_node.title
WHERE drupal_node.nid=drupal_content_type_housing_application.field_housing_inst_affil_nid
h/t devshed
Posted by kkwaiser at October 2, 2012 12:22 PM