我有一个表(出勤),用于存储员工的出勤数据。每天,管理员登录到他的系统中,选择日期(该日期),并将该员工标记为该日期的在场或缺席。这些记录存储在出勤表中。
我想检索当月标记为EmpId
的当月特定present / absent
的所有记录。
出勤表的列名是:
1.EmpId - numeric
2.date:date type
3.status(either present/absent)-varchar
我想编写一个查询来检索当前月份中特定
EmpId
(例如1)的所有记录,其中status="present"
我想编写另一个查询来检索当前月份中特定
EmpId
(例如1)的所有记录,其中status="absent"
任何帮助,将不胜感激 。
最佳答案
您可以使用year() and month()函数获取当月的记录:
select * from attendance
where empid=... and year(date)=year(curdate()) and month(date)=month(curdate()) and status=...
您需要从应用程序中提供员工ID和状态。
关于php - 如何选择与当月有关的记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39097984/