解决方案 »

  1.   

    http://bbs.csdn.net/topics/390830914参考我这里写的
      

  2.   

    你是试试看是否可行
    select * , case when A.id=SON1.id and A.type=SON1.type then  SON1.Source    
         when A.id=SON2.id and A.type=SON2.type then  SON2.Source   end  as [Source]from A left join SON1  ON A.id=SON1.id and A.type=SON1.typeleft join SON2 ON  A.id=SON2.id and A.type=SON2.type 
      

  3.   

    我想能不能实现自动的呢 自动根据父表type值 去查对应的子表,而不是每个子表写个查询.
      

  4.   

    自动的话,可以考虑建立两张视图View。个人想不出其他自动的方法了
      

  5.   

    数据表设计可否改为这样:只用一个子表,子表增加 type 列,如:id        pid        type        source
    1         1           1              100
    2         2           2              90或许主表都不需要 type 列。不知道楼主的业务逻辑,瞎猜的
      

  6.   

    请问结果中李四的source=90是怎样得来的? SON2表没有id=2的记录.