在IN CLAUSE中找不到其他表中的结果

时间:2017-10-30 10:10:44

标签: sql oracle

我有两个表t1和t2。 我在t1表中有特定的100条记录。我想在100条记录中找到t2表中没有的记录。 我尝试使用左连接,但它给我的结果存在t2表

PS-t1表有超过100条记录,我有特别记录,我想搜索。 还有t1.ID = t2.ID

1 个答案:

答案 0 :(得分:0)

您的错误位置必须是a.id in而不是b.id in

select a.id from t1 a Left out join t2 b on (A.id=b.id) Where b.id is NULL and a.id in (--100 records)

因为b.id不能是null,而是列表的值