现在有三个表 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一样的不显示出来
请问现在该怎么写
表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一样的不显示出来
请问现在该怎么写
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
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
select * from a
union all
select paydate from b