gpt4 book ai didi

mysql - 我想知道正确的左连接

转载 作者:行者123 更新时间:2023-11-29 00:42:52 24 4
gpt4 key购买 nike

我有这个查询,我希望必须根据给定的条件显示表 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

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

最佳答案

试试这个:

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

关于mysql - 我想知道正确的左连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11502581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com