查联动数据,不需要把数据查出来在判断是否有关联,可以在查询时就直接判断有无关联
SELECT air_.id, air_.`name`, air_.orgz_code, analog_.id FROM sb_airinfo_orgz air_ LEFT JOIN f_analog_link_air link_ ON link_.air_id = air_.id LEFT JOIN b_analoginfo analog_ ON ( analog_.id = link_.analog_id AND analog_.id = 16 ) WHERE air_.orgz_code LIKE "%1001%"
id1不为null就是有关联,为null就是没有关联