select t.*,0 as keyid from t
where not exists(select 1 from planadmin where city_name = t.F18 and county_name = t.F19 and charindex(t.F20,'、'+retwo+',') >0 and pro_name is not null )
where not exists(select 1 from planadmin where city_name = t.F18 and county_name = t.F19 and charindex(t.F20,'、'+retwo+',') >0 and pro_name is not null )
(
select t.*,case when exists(select 1 from planadmin where city_name = t.F18 and county_name = t.F19 and charindex(t.F20,'、'+retwo+',') >0 and pro_name is not null )then 1 else 0 end as keyid from t
) A where keyid=0