UPDATE `order` t1 JOIN `order` t2 ON (t1.sfzh ='x' AND t2.sfzh = 'x') SET t1.`exam_id` = t2.`exam_id`,t1.`site_id`=t2.`site_id`,t2.`exam_id` = t1.`exam_id`,t2.`site_id`=t1.`site_id`;