Det ser ud til, at du leder efter betinget aggregering:
vælg u.user_id, u.username, min(case when a.action ='IN' then a.dateTime end) 'in', max(case when a.action ='OUT' then a. dateTime end) `out`from user u indre join user_attendance a on u.user_id =a.user_idgroup by u.user_id, u.username, date(a.dateTime)order by u.user_id, date(a.dateTime)
| bruger_id | brugernavn | i | ud || ------- | -------- | ------------------ | ------------------ || 1 | tiger | 01-10-2019 08:00:00 | 01-10-2019 14:00:00 || 1 | tiger | 2019-10-02 08:00:00 | 2019-10-02 14:00:00 || 2 | puh | 01-10-2019 08:00:00 | 01-10-2019 14:00:00 || 2 | puh | 2019-10-02 08:00:00 | 2019-10-02 14:00:00 |