select D.DepartName,V.FileID,PL.LineDesc,PL.PhoneNO as benji,V.PhoneNO,V.RecTime,V.RecLength,V.iState,V.isCallOUT 
from DepartInfo D, VoiceFileList V ,PhoneLine PL 
where V.LineID=PL.LineID and D.DepartID=PL.DepartID 
and FileID in (
    select FileID from QueryRecord where UserID=147 and (QueryTime>='2011-07-13 16:01:06' and QueryTime<='2011-07-13 16:11:06') 
      ) limit 0,8子查询里面有多条数据,所以用in的话,重复的数据只会显示一条,我要的是所有的数据,重复的也要显示,请问这段sql语句怎么改

解决方案 »

  1.   

    试下 
    select D.DepartName,V.FileID,PL.LineDesc,PL.PhoneNO as benji,
        V.PhoneNO,V.RecTime,V.RecLength,V.iState,V.isCallOUT
    from DepartInfo D, VoiceFileList V ,PhoneLine PL,
     (
       select FileID as fid from QueryRecord where UserID=147 and (QueryTime>='2011-07-13 16:01:06' and QueryTime<='2011-07-13 16:11:06')
      ) fids
    where V.LineID=PL.LineID and D.DepartID=PL.DepartID
    and V.FileID=fids.fid
    limit 0,8