一、Oracle两个表中如何让一个表排除另一个表已有的字段?
1.使用场景 , 现在有 a,b两个表,现在需要让你查处 a 表中的全部数据且不包含有和b表相同的两个字段
select distinct jt.taskid,jt.tcode,t.tproposer,b.typebname,jt.spvstage from zjdgl.zjdgl_jg_task jt
left join zjdgl.zjdgl_trans t
on jt.tid = t.tid
left join dic.dic_district d
on t.accdist = d.code
left join zjdgl.cfg_typeb b
on t.typeb = b.typebcode
left join zjdgl.zjdgl_jg_inspection ji
on ji.tcode = jt.tcode
where d.code = '41' and (jt.tcode,jt.spvstage) not in (select t.tcode,t.spvstage from ZJDGL_JG_INSPECTION t where ptype = '2')
关键代码 where d.code = ‘41’ and (jt.tcode,jt.spvstage) not in (select t.tcode,t.spvstage from ZJDGL_JG_INSPECTION t where ptype = ‘2’)