我有2个表emptimein
和emptimeoutOT
。两者都有相同的字段。
table1
Emptimein
ID Date TimeIn
table2
ID Date TimeOutOT
我想加入两个表来组合emptimein
表的第一行和
emptimeout
表
我想要一个像这样的结果
ID Timein TimeOutOT
答案 0 :(得分:0)
案例1#
select Etimein.ID,Etimein.TimeIN,
Etimeout.TimeOutOT
from databasename.Emptimein as Etimein left outer join
databasename.Emptimeout as Etimeout on Etimein.ID=Etimeout.ID
and Etimein.date=Etimeout.date
where Etimein.date between 'yyyy-mm-dd' and 'yyyy-mm-dd'
group by Etimein.id
order by Etimein.id
;
案例2#
select Etimein.ID,Etimein.TimeIN,
Etimeout.TimeOutOT
from databasename.Emptimein as Etimein left outer join
databasename.Emptimeout as Etimeout on Etimein.ID=Etimeout.ID
and Etimein.date=Etimeout.date
where Etimeout.date between 'yyyy-mm-dd' and 'yyyy-mm-dd'
group by Etimein.id
order by Etimein.id
;
答案 1 :(得分:0)
您可以尝试以下查询:
SELECT EI.ID,EI.Timein,EO.TimeOutOT FROM emptimein EI
LEFT JOIN emptimeoutOT EO ON EI.ID = EO.ID
AND Etimein.date = Etimeout.date
WHERE Etimein.date BETWEEN 'yyyy-mm-dd' AND 'yyyy-mm-dd'
如果我误解了这些要求,请告诉我。