表T1:(#depart_id, c_id)
表T2:(#No, c_id, re, date)现在我想找出,表T2的数据,条件是 T2中的c_id不在T1中,请问该怎么写呢?SELECT No, c_id, re, date from T2 where 。怎么写?谢谢
表T2:(#No, c_id, re, date)现在我想找出,表T2的数据,条件是 T2中的c_id不在T1中,请问该怎么写呢?SELECT No, c_id, re, date from T2 where 。怎么写?谢谢
不存在的改成not exists就行了
不知道行不
SELECT No, c_id, re, date from T2 where t2.c_id not in(select t1.c_id from t1,t2 where t1.c_id=t2.c_id)
就很好了
select *
from T2
where not exists(
select 1
from T1
where T1.c_id=T2.c_id
)