U kunt een zoekopdracht als deze gebruiken:
SELECT empID, emp_day, MAX(am_in1) as am_in, MAX(am_out1) as am_out, MAX(pm_in1) as pm_in, MAX(pm_out1) as pm_out
FROM (
SELECT empID, DATE_FORMAT(`time_stamp`,'%e') as emp_day,
CASE WHEN am_pm='am' AND in_out='in' THEN DATE_FORMAT(`time_stamp`,'%T') ELSE '' END as am_in1,
CASE WHEN am_pm='am' AND in_out='out' THEN DATE_FORMAT(`time_stamp`,'%T') ELSE '' END as am_out1,
CASE WHEN am_pm='pm' AND in_out='in' THEN DATE_FORMAT(`time_stamp`,'%T') ELSE '' END as pm_in1,
CASE WHEN am_pm='pm' AND in_out='out' THEN DATE_FORMAT(`time_stamp`,'%T') ELSE '' END as pm_out1
FROM attendance
) as o
GROUP BY empID, emp_day
De subquery formatteert de gewenste kolommen en de belangrijkste querygroepen om één rij per werknemer per dag te krijgen.
EDIT:hier is een viool