I think I know what you mean, and if that is the case it’s actually a straightforward operation.
Firstly get all the object_id
s from the term_relationship
table.
$results = $wpdb->get_results("SELECT `object_id` FROM $wpdb->term_relationships WHERE `term_taxonomy_id` = 18");
And then run through each of those values and update_post_meta to 18.
foreach ( $results as $result )
update_post_meta($result, '_category_permalink_', '18', true);
It couldn’t be that simple could it?