问题描述
我有2个表格
employee_master
emp_id emp_name状态createddate由updateddate创建更新由
1 Kiran 1 2015-11- 13 1 2015-11-13 1
2 Praju 1 2015-11-13 1 2015-11-13 1
3 e 0 2015-11-13 1 2015-11-13 1
4 Amol 1 2015-11-13 1 2015-11-13 1
5 Kanchan1 1 2015-11-14 1 2015-11-14 1
6 Archana 1 2015-11-18 1 2015-11 -18 1
attendance_master
att_id emp_id today_date presenty plant_id
1 2 2015-11-26 A 2
17 1 2015-11-26 H 1
18 4 2015-11-26 P 1
如果我搜索2015-11-26然后我应该获得
emp_id emp_name presenty
1 Kiran H
5 Kanchan1
6 Archana
AND
如果我搜索2015年-11-27然后我应该得到
emp_id emp_name presenty
1 Kiran
2 Praju
4 Amol
5 Kanchan1
6 Archana
我的查询是:
SELECT employee_master.emp_id,employee_master.emp_name,IFNULL(attendance_master.presenty,'')AS presenty,attendance_master.today_date
FROM employee_master LEFT JOIN attendance_master ON attendance_master.emp_id = employee_master.emp_id
WHERE employee_master.Status = 1 AND
attendance_master.today_date ='2015-11-26'
代码块添加 - OriginalGriff [/ edit]
I have 2 TABLES
employee_master
emp_id emp_name STATUS createddate createdby updateddate updatedby 1 Kiran 1 2015-11-13 1 2015-11-13 1 2 Praju 1 2015-11-13 1 2015-11-13 1 3 e 0 2015-11-13 1 2015-11-13 1 4 Amol 1 2015-11-13 1 2015-11-13 1 5 Kanchan1 1 2015-11-14 1 2015-11-14 1 6 Archana 1 2015-11-18 1 2015-11-18 1
attendance_master
att_id emp_id today_date presenty plant_id 1 2 2015-11-26 A 2 17 1 2015-11-26 H 1 18 4 2015-11-26 P 1
IF i search FOR 2015-11-26 THEN i should get
emp_id emp_name presenty 1 Kiran H 5 Kanchan1 6 Archana
AND
IF i search FOR 2015-11-27 THEN i should get
emp_id emp_name presenty 1 Kiran 2 Praju 4 Amol 5 Kanchan1 6 Archana
My QUERY IS :
SELECT employee_master.emp_id,employee_master.emp_name,IFNULL(attendance_master.presenty,'') AS presenty,attendance_master.today_date
FROM employee_master LEFT JOIN attendance_master ON attendance_master.emp_id=employee_master.emp_id
WHERE employee_master.Status=1 AND
attendance_master.today_date='2015-11-26'
[edit]Code block added - OriginalGriff[/edit]
这篇关于如何使用Presenty获取员工姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!