select GetNoticeNo,OtherNo,AppntNo,SumDuePayMoney 
from ljsPay,LPEdorMain,LABranchGroup 
where othernotype = '3' and LPEdorMain.EdorNo = ljsPay.OtherNo 
      and ljsPay.AgentGroup = LABranchGroup.AgentGroup
union all
select GetNoticeNo,OtherNo,AppntNo,SumDuePayMoney 
from ljsPay,LPGrpEdorMain,LABranchGroup 
where othernotype = '3' and LPGrpEdorMain.EdorNo = ljsPay.OtherNo 
      and ljsPay.AgentGroup = LABranchGroup.AgentGroup;

解决方案 »

  1.   

    select GetNoticeNo,OtherNo,AppntNo,SumDuePayMoney 
    from ljsPay,LPEdorMain,LABranchGroup 
    where othernotype = '3' and LPEdorMain.EdorNo = ljsPay.OtherNo 
          and ljsPay.AgentGroup = LABranchGroup.AgentGroup
    union 
    select GetNoticeNo,OtherNo,AppntNo,SumDuePayMoney 
    from ljsPay,LPGrpEdorMain,LABranchGroup 
    where othernotype = '3' and LPGrpEdorMain.EdorNo = ljsPay.OtherNo 
          and ljsPay.AgentGroup = LABranchGroup.AgentGroup;
      

  2.   

    如果说就是把两个查询的结果合并的话,用union是可以的;union all的话可能会有重复的数据,union会去掉重复的数据,但是如果你确定两个查询结果中不可能有重复或者是你所要求的结果可以有重复,用union all会更好。
    但是我不明白是不是你就是这么简单的要把两个表的结果合并!
      

  3.   

    YES!使用数据连接就OK了
     
    注意要使用union all,否则union有相同记录只显示一条
      

  4.   

    谢谢大家,我已经解决了,用的是1楼的方法,也谢谢3,4,5楼,让我知道union的用法 但是100分太少了 我尽量公平,如果不满,请大家见谅!