select t1.*, t2.*from 真实表 t1 full join 临时表 using (id) //using也可写成on t1.id=t2.idwhere t1.f!=t2.f or (t1.f is null and t2.f is not null) or (t1.f is not null and t2.f is null)