求sql语句, 按一个关联字段 查询表1在表2中没有的记录 ,表2是表1的子集,想把补集查出来,谢谢!

2024-12-02 13:22:21
推荐回答(2个)
回答1:

select t1.id from t1 right outer join t2 on t1.id=t2.id where t2.id=null

回答2:

SELECT *
FROM t1
WHERE t1.id_ not in (select id_ from t2)