我有两张桌子 mstEmp 和每日出勤。现在我想运行一个查询
SELECT
mstEmp.empname,
dailyattendance.InTime,
dailyattendance.OutTime,
mstEmp.teamtype
FROM
dailyattendance ,
mstEmp mstEmp
where
dailyattendance.HolderName IN (
select mstEmp.empname from mstEmp where mstEmp.teamtype='$chk' )
此处 teamtype 匹配,相应的名称从 mstEmp 获取,然后与 dailyattendance.HolderName 匹配以显示结果。
答案 0 :(得分:0)
这个怎么样::
SELECT
mstEmp.empname,
dailyattendance.InTime,
dailyattendance.OutTime,
mstEmp.teamtype
FROM dailyattendance inner join mstEmp on (dailyattendance.HolderName = mstEmp.empname)
where mstEmp.teamtype='$chk'
group by mstEmp.empname