1

我有这个查询,我希望表 mstemp 的所有记录必须根据给定的条件显示。

SELECT 
    mstEmp.empname, InDate, dailyattendance.InTime,
    dailyattendance.OutTime, mstEmp.teamtype 
FROM 
    mstEmp
LEFT JOIN 
    dailyattendance ON (dailyattendance.HolderName = mstEmp.empname ) 
WHERE 
    mstEmp.teamtype = '$chk' 
    AND (InDate BETWEEN '$from' AND '$to' )
ORDER BY 
    InDate ASC

但似乎这个查询不起作用。

4

1 回答 1

1

尝试这个:

SELECT mstEmp.empname, InDate, dailyattendance.InTime,
       dailyattendance.OutTime, mstEmp.teamtype 
FROM mstEmp
  LEFT JOIN dailyattendance 
    ON (dailyattendance.HolderName = mstEmp.empname ) AND (InDate BETWEEN '$from' AND '$to' )
WHERE mstEmp.teamtype = '$chk' 
ORDER BY InDate ASC
于 2012-07-16T10:47:57.950 回答