我正在开发一个具有白天和黑夜时间表的计时系统。
这是我的桌子[tbl_datetime_records]
+---------------+---------------+--------------------+
| biometrics_id | employee_name | date_time_logs |
+---------------+---------------+--------------------+
| 1221 | EMPLOYEE 1 | 2014-07-11 09:00 |
| 1221 | EMPLOYEE 1 | 2014-07-11 18:00 |
| 1221 | EMPLOYEE 1 | 2014-07-12 08:54 |
| 1221 | EMPLOYEE 1 | 2014-07-12 18:01 |
| 7445 | EMPLOYEE 2 | 2014-07-11 09:00 |
| 7445 | EMPLOYEE 2 | 2014-07-11 18:00 |
| 7445 | EMPLOYEE 2 | 2014-07-12 08:54 |
| 7445 | EMPLOYEE 2 | 2014-07-12 18:01 |
| 2332 | EMPLOYEE 3 | 2014-07-11 18:00 |
| 2332 | EMPLOYEE 3 | 2014-07-12 02:00 |
| 2332 | EMPLOYEE 3 | 2014-07-12 02:01 |
| 2332 | EMPLOYEE 3 | 2014-07-12 18:00 |
| 2332 | EMPLOYEE 3 | 2014-07-13 02:03 |
| 4114 | EMPLOYEE 4 | 2014-07-11 08:43 |
| 4114 | EMPLOYEE 4 | 2014-07-11 08:44 |
| 4114 | EMPLOYEE 4 | 2014-07-11 14:02 |
| 4114 | EMPLOYEE 4 | 2014-07-12 08:56 |
| 4114 | EMPLOYEE 4 | 2014-07-12 18:04 |
| 4114 | EMPLOYEE 4 | 2014-07-13 09:00 |
+---------------+---------------+--------------------+
我将其过滤为FIRST IN和LAST OUT
条件:
输出应为:
+---------------+---------------+------------------+------------------+
| biometrics_id | employee_name | date_time_in | date_time_out |
+---------------+---------------+------------------+------------------+
| 1221 | EMPLOYEE 1 | 2014-07-11 09:00 | 2014-07-11 18:00 |
| 1221 | EMPLOYEE 1 | 2014-07-12 08:54 | 2014-07-12 18:01 |
| 7445 | EMPLOYEE 2 | 2014-07-11 09:00 | 2014-07-11 18:00 |
| 7445 | EMPLOYEE 2 | 2014-07-12 08:54 | 2014-07-12 18:01 |
| 2332 | EMPLOYEE 3 | 2014-07-11 18:00 | 2014-07-12 02:01 | ---> NIGHT SHIFT
| 2332 | EMPLOYEE 3 | 2014-07-12 18:00 | 2014-07-13 02:03 | ---> NIGHT SHIFT
| 4114 | EMPLOYEE 4 | 2014-07-11 08:43 | 2014-07-11 14:02 | ---> HALF DAY
| 4114 | EMPLOYEE 4 | NULL | 2014-07-12 18:04 | ---> NO TIME IN
| 4114 | EMPLOYEE 4 | 2014-07-1309:00 | NULL | ---> NO TIME OUT
+---------------+---------------+------------------+------------------+
在这种情况下,我仍然没有任何想法。我正在使用MYSQL / PHP / LARAVEL