现在有三个表 a b c 
表a PayCalculation 里面有(paydate empid 等等) 
表b Employee有(empid dateleft 等) 
表c 里面(比表a少了几个列名) 现已经表a跟表b合并起来 
SELECT PayCalculation.*, Employee.DateLeft FROM PayCalculation INNER JOIN Employee ON Employee.EmployeeID = PayCalculation.EmpID 现在想把a.* 全都显示出来 
又想把表c里面的paydate 一起查询出来 
但是除了paydate 其他都不显示出来
然后paydate年月跟表a一样的不显示出来 
请问现在该怎么写

解决方案 »

  1.   

    应该是这个意思
    select
      a.*,b.DateLeft,c.paydate 
    from
      PayCalculation a
    inner join
      Employee b
    ON 
      b.EmployeeID = a.EmpID 
    inner join
      (select * from c where not exists(select 1 from PayCalculation where year(paydate)=year(c.paydate) and month(paydate)=month(c.paydate))
    on
      b.EmployeeID =c.EmpID
      

  2.   

    month 不同也要显示呢?? 
      

  3.   

    select
      a.*,b.DateLeft,c.paydate 
    from
      PayCalculation a
    inner join
      Employee b
    ON 
      b.EmployeeID = a.EmpID 
    inner join
      (select * from c where not exists(select 1 from PayCalculation where year(paydate)=year(c.paydate) )
    on
      b.EmployeeID =c.EmpID
      

  4.   

    用个union all了
    select * from a
    union all
    select paydate from b