I have two tables
Horas (id, aluno_id, atividade_id)
and
Atividades (id, emblema_id)
In addition to returning all the badges, I need to return a column that tells me if that student owns it. To know if he has, it is enough that he has gained hours in the activity.
Of the two forms I tried, I was able to return only the emblems he had and all the emblems at once, but without distinguishing which of them he actually possessed. As an example of the filled-in Hours and Activities tables, respectively, follows:
id | aluno_id | atividade_id
1 | 1 | 1
id | emblema_id
1 | 1
2 | 2
The expected result should be:
emblema_id | possui
1 | Sim
2 | Não
...
In the expected result example above, I show that the student has badge 1 because he has earned hours in the corresponding activity. However, it does not have the emblem 2, because it did not gain hours.