我将离开ID为空的join table2。 这将使您更快地返回数据。
select a.id from table1 a left join table2 b on a.id = b.id and b.id is null