1)select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  fileid  not  in  (select  infomationid  from  infochargehistory)    
 
 
2)select  *  from  v_file    where  cri_userid  =  2  and  customerid  =  33333  and  fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate)  
 
 
如果FILEID  满足第一个条件就查出来,满足第二个条件就查出来  

解决方案 »

  1.   

    1)select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  fileid  not  in  (select  infomationid  from  infochargehistory)    
     
     
    2)select  *  from  v_file    where  cri_userid  =  2  and  customerid  =  33333  and  fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate)  
     
     
    这两条语句都是跟FILEID 有关系的,如果FILEID 满足第一个条件就查出来,FILEID 满足第二个条件就查出来 ,都要在一句SQL语句中实现
      

  2.   

    引用"如果FILEID  满足第一个条件就查出来,满足第二个条件就查出来"
    你不是已经查出来了?
      

  3.   

    都要在一句SQL语句中实现
      

  4.   

    假如是要查询满足这2个条件的结果 那就这样
    1)select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  (fileid  not  in  (select  infomationid  from  infochargehistory)) or (fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate) )
      

  5.   

    漏掉一个刮号
    select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  ((fileid  not  in  (select  infomationid  from  infochargehistory)) or (fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate) ))
      

  6.   


    --这个意思?
    select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  (fileid  not  in  (select  infomationid  from  infochargehistory) or fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate) )
      

  7.   

    或者用 union 也可以吧
      

  8.   

    是不是这个意思???
    select  *  from  v_file  where  cri_userid  =  2  and  customerid  =  33333  and  fileid  not  in  (select  infomationid  from  infochargehistory)    
      and not exists((select  *  from  v_file    where  cri_userid  =  2  and  customerid  =  33333  and  fileid  in  (select  infomationid  from  infochargehistory  where  v_file.cri_enddate>infochargehistory.cri_enddate)) as b
                     Where v_file.关键字1=b.关键字1
                       and v_file.关键字2=b.关键字2)