select bf.factory_name, bl."id", bl.p_type, bl.loc_no, bl.loc_name, bl.loc_desc, bl.loc_type, bl.loc_addr, bl.loc_map, bl.loc_status, bl.loc_remark, bl.create_time, bl.loc_group, bw.id workstation_id, bw.workstation_no, bwl.location_type FROM basic_location bl left join basic_factory bf on bf."id" = bl.factory_id left join basic_workstation_location bwl on bwl.location_id = bl."id" left join basic_workstation bw on bw.id = bwl.workstation_id where bl.active = true select bf.factory_name, wl."id", wl.p_type, wl.loc_no, wl.loc_name, wl.loc_desc, wl.loc_type, wl.loc_addr, wl.loc_map, wl.loc_status, wl.loc_remark, wl.create_time, wl.ifs_location, wl.ifs_location_group, wl.loc_group FROM basic_location wl left join basic_factory bf on wl.factory_id = bf."id" where wl.active = true UPDATE basic_location SET loc_no = null where id in #{item}