Combo of db_query and db_insert

db_query() is not recomended for INSERT, UPDATE, or DELETE queries. As per its documentation, Those should be handled via db_insert(), db_update() and db_delete() respectively.

So for an example, we want to copy data from one field's table and put it to another field's table.

We take this as an example where we are copying data of one field [field_data_field_from] and putting it into other one [field_data_field_to] ...

$result = db_query('SELECT a.* 
  FROM {field_data_field_from} a
  LEFT JOIN {field_data_field_to} b ON a.entity_id = b.entity_id
  AND a.entity_type = b.entity_type
  WHERE b.entity_id IS NULL'
);

$records = $result->fetchAll();
foreach ($records as $record) {
  db_insert('field_data_field_to') // Table name no longer needs {}
        ->fields(array(
          'entity_type' => $record->entity_type,
          'bundle' => $record->bundle,
          'deleted' => $record->deleted,
          'entity_id' => $record->entity_id,
          . // All Columns
          .
          .
          .
        ->execute();
}