我有一个表(考勤)来存储employees.Every日的考勤数据,管理员登录到他的系统中,选择日期(在那个日期),并将员工标记为该日期的现职或缺勤。这些记录存储在考勤表中。
我希望检索当前月份某个特定EmpId
的所有记录,其中考勤标记为present / absent
之一。
考勤表的列名如下:
1.EmpId - numeric
2.date:date type
3.status(either present/absent)-varchar
EmpId
(例如1)当前月份的所有记录,其中status="present"
EmpId
(例如1)的所有记录,其中status="absent"
任何帮助都将不胜感激。
发布于 2016-08-23 15:01:14
我尝试过这个查询,它运行得非常完美:
select * from attendance
where emp_id=1 and year(date)=year(curdate()) and month(date)=month(curdate()) and status='present';
发布于 2016-08-23 10:04:03
您可以使用年份()和月份()函数获取当前月份的记录:
select * from attendance
where empid=... and year(date)=year(curdate()) and month(date)=month(curdate()) and status=...
您需要从应用程序中提供员工id和状态。
发布于 2016-08-23 10:24:40
试试这个:
Select * from attendance
where date >= 'YOUR DATE' AND date <= 'YOUR DATE' AND status='Present OR Absent(Any)'
或者你可以用这个:
SELECT * FROM attendance
WHERE Status='Present OR Absent(Any)' AND date BETWEEN value1 AND value2
https://stackoverflow.com/questions/39097984
复制相似问题