大家好,我有一条语句,可以执行,只是感觉写的很搓,请教高手优化下现在有两个表:Table1、Table2 ,Table2中记录了Table1和其他表中的关系
需求:根据关键字TAB1_ID,查找不在Table2表中,而在Table1中的数据如下:Table1
{TAB1_ID,NAME,...
1,a;
2,b
3,c
4,d
5,e
}Table2
{TAB2_ID,TAB1_ID,...
1,2
2,3
3,4
}select a.TAB1_ID 
from Table1 a 
where a.TAB1_ID in(3,4,5) 
     and a.TAB1_ID not in (select b.TAB1_ID 
                               from Table2 b 
                               where b.TAB1_ID in (3,4,5))上面用了in 和not in,感觉写的不怎么对头,请高手帮优化下啊,不胜感激~~