0

我有 2 张表mstEmpdailyattendance。现在我想运行一个查询

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匹配以显示结果。

4

1 回答 1

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
于 2012-07-11T10:27:47.883 回答