UPDATE submission_files sf, review_assignments ra SET sf.file_stage = 5, sf.assoc_type = 517, sf.assoc_id = ra.review_id WHERE ra.reviewer_file_id IS NOT NULL AND sf.file_id = ra.reviewer_file_id UPDATE submission_files sf, review_assignments ra SET sf.file_stage = 5, sf.assoc_type = 517, sf.assoc_id = ra.review_id WHERE ra.reviewer_file_id IS NOT NULL AND sf.file_id = ra.reviewer_file_id UPDATE submission_files SET file_stage = 5, assoc_type = 517, assoc_id = ra.review_id FROM review_assignments ra WHERE ra.reviewer_file_id IS NOT NULL AND submission_files.file_id = ra.reviewer_file_id INSERT INTO review_round_files (submission_id, review_round_id, stage_id, file_id, revision) SELECT ra.submission_id, ra.review_round_id, 3, ra.reviewer_file_id, sf.revision FROM review_assignments ra, submission_files sf WHERE ra.reviewer_file_id IS NOT NULL AND sf.file_id = ra.reviewer_file_id UPDATE review_assignments SET reviewer_file_id = NULL WHERE reviewer_file_id IS NOT NULL