#1
I have two tables. With one to many relationship
1) Profile (one)
2) Attendance (many)

Profile Table

id, name
1, Freiza
2, James
3, Rita

Attendance Table
id, datetime, fk_profile
1, 08/01/2022, 1
2, 08/02/2022, 1
3, 08/03/2022, 1
4, 08/01/2022, 2
5, 08/03/2022, 2
Is it possible to get data like
name, date1, date2, date3 ..... date31
Freiza, 08/01/2022, 08/02/2022, 08/03/2022, Null, Null......
James, 08/01/2022, Null, 08/03/2022..
#2
I found an ugly answer. But I think it is the best alternative that I could come up with. Use GROUP_CONCAT

SELECT profiles.name , GROUP_CONCAT(DATE(attendances.dtime)),GROUP_CONCAT(attendances.file) from profiles
inner join attendances on profiles.id = attendances.profiles_id
where dtime between '2022-08-22' and '2022-09-22'
#3
Hello,
This is a good time to use the Query Builder from the Trongate app.
Here is the link:
https://trongate.io/docs/information/graphical-query-builder

Try using an outer join
Dan
#4
Dan, Freiza is after piviot table which the querybuilder won't do on this occasion.

Freiza, your query is fine, well done. Or you could explore PIVOT or UNION ALL if you want but they are just as ugly and possibly more complex that GROUP_CONCAT