【问题标题】:How to Combine multiple column into one in php SQL如何在php SQL中将多列合并为一列
【发布时间】:2016-10-13 08:36:12
【问题描述】:

I have this data. Can someone help how can I combine them into one?

id  employeeID   date         timein    timeout     timein1     timeout1
1   12286        2016-09-10   08:08:00  00:00:00    00:00:00    00:00:00
2   12286        2016-09-10   00:00:00  12:08:32    00:00:00    00:00:00
3   12286        2016-09-10   00:00:00  00:00:00    12:41:54    00:00:00
4   12286        2016-09-10   00:00:00  00:00:00    00:00:00    17:10:05
5   12286        2016-10-10   07:41:05  00:00:00    00:00:00    00:00:00
6   12286        2016-10-10   00:00:00  12:15:00    00:00:00    00:00:00
7   12286        2016-10-10   00:00:00  00:00:00    12:35:15    00:00:00
8   12286        2016-10-10   00:00:00  00:00:00    00:00:00    17:15:15

This is the output that I wanted. Help me. Thanks

id  employeeID   date         timein    timeout     timein1     timeout1
1   12286        2016-09-10   08:08:00  12:08:32    12:41:54    17:10:05
2   12286        2016-10-10   07:41:05  12:15:00    12:35:15    17:15:15

【问题讨论】:

标签: php mysql database multidimensional-array phpmyadmin


【解决方案1】:

如果是我,我可能会采用大致如下的架构:

id  employeeID   datetime             activity
1   12286        2016-09-10 08:08:00  in 
2   12286        2016-09-10 12:08:32  out  
3   12286        2016-09-10 12:41:54  in
4   12286        2016-09-10 17:10:05  ...

【讨论】:

    【解决方案2】:

    没有字段的临时解决方案:id

    选择employeeID、日期、max(timein)、max(timeout)、max(timein1)、max(timeout1) 按员工ID、日期分组

    最好将 00:00:00 的插入查询修改为 null

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多