update A as phg left join B as pb on phg.patient_id = pb.patient_id set phg.double_flag = case when pb.live_place_community = pb.census_register_community then 0 #否双列管 when pb.live_place_community != pb.census_register_community then 1 #是双列管 end