Select ... from a,b,c 
where ... 
and .. in ( select .. from ... where ... and exists(..))

解决方案 »

  1.   

    from oa_crm_xsjlb a,oa_crm_khxx b,rs_ygb c
    三表的INNET JOIN查询.
    EXISTS
    指定一个子查询,检测行的存在。 
    IN
    确定给定的值是否与子查询或列表中的值相匹配。
      

  2.   

    查询 表oa_crm_xsjlb 中所有字段和表oa_crm_khxx中字段khmc及表rs_ygb 中字段ygxm 组
    成的记录,条件是满足表oa_crm_xsjlb 中字段 khbh 与 表oa_crm_khxx中字段khbh 相等,并且
    表oa_crm_xsjlb 中字段fzr与 表rs_ygb 中字段ygbh 相等。
      

  3.   

    select a.*,b.khmc,              c.ygxm 
    --查询  显示oa_crm_xsjlb表的全部列 rs_ygb的ygxm列from oa_crm_xsjlb a,oa_crm_khxx b,rs_ygb c 
    --从 oa_crm_xsjlb 表和 oa_crm_khxx表和 rs_ygb表 where a.khbh=b.khbh and              a.fzr=c.ygbh 
    --三个表的关联是 a的khbh和b的khbh相连 a的fzr和c.ygbh 相连and b.dq in (
    --并且b.dq在后面这个结果集中select dqbh as dq from oa_crm_ygdqqxb
    --这个结果集是从oa_crm_ygdqqxb表中 where ygbh='xxxxx'
    --条件是 ygbh等于一个参数 and exists(select a2.cpbh 
    --并且后面的这个结果集不是空的from oa_crm_ygcpqxb a2,oa_crm_khcpb b2 where a2.cpbh=b2.cpbh--在oa_crm_ygcpqxb a2,oa_crm_khcpb b2 两个表根据cpbh相连 and b2.khbh=b.khbh 
    --这里是说 子查询里的b2的khbh等于外面大查询的表b的khbh连接and a2.ygbh='xx')
    --并且子查询里的ygbh='xx'----------------------------------------
    附:
    --exists的用法:select * from xx where exists(select * from yy where yy.id=xx.id)--等效:select * from xx where id in (select id from yy)