三张表:t_icitem,,Icstockbill,,Icstockbillentry 
t_icitem中有字段:fname,fnumber,fitemid,FTrack
Icstockbill中有字段:fintreid,fdate,fbillno
Icstockbillentry 中有字段:fintreid,fitemid
(Icstockbill和Icstockbillentry关联查出fdate为2010-01-26到2010-02-05之间,再和t_icitem关联,过滤出Ftrack<>81)
三张表关联需要查询出的结果为 fbillno,fnumber,fname

解决方案 »

  1.   

    不知道是否理解正确...SELECT A.fbillno
          ,C.fnumber
          ,C.fname
    FROM Icstockbill A
    INNER JOIN Icstockbillentry B ON A.fintreid = B.fintreid
    INNER JOIN t_icitem C ON C.fitemid = A.fitemid
    WHERE A.fdate BETWEEN '2010-01-26' AND '2010-02-05'
    AND C.Ftrack<>81
    GO
      

  2.   


    select  aa.fbillno ,
            c.fnumber ,
            c.fname
    from    ( select    a.fbillno ,
                        b.fintreid ,
                        b.fitemid
              from      Icstockbill a
                        left join Icstockbillentry b on a.fintreid = b.fintreid
              where     a.fdate between '2010-01-26' and '2010-02-05'
            ) aa
            left join t_icitem c on aa.fitemid = c.fitemid
    where   c.Ftrack <> 81
      

  3.   

    select fbillno,fnumber,fname
    from Icstockbill i join Icstockbillentry ic on i.fintreid=ic.fintreid
                       join t_icitem t on t.fitemid=ic.fitemid
    where  i.fdate BETWEEN '2010-01-26' AND '2010-02-05'AND t.Ftrack<>81