我有这个查询,我希望必须根据给定的条件显示表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
但似乎这个查询无效。
答案 0 :(得分: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