select * from t1 left join t2 on t1.id = t2.id union all select * from t1 right join t2 on t1.id = t2.id where t1.id is null;