0
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 has it. To know if he has, just that he has earned hours in activity.
Of the two ways that I tried, I was able to return only the emblems that he had and all the emblems at once, but without discriminating which one he actually had. As an example of the tables Hours and Activities filled, 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 above expected result example, I demonstrate that the student has badge 1 because he has earned hours in the corresponding activity. However, it does not have the emblem 2, as it did not gain hours.
How will I know how to join the tables? Put the exact structure of them and some 3 example data for us can mirror more accurately
– Cayo Da Silva Lima
How to join tables? In the hours table the activity attribute corresponds to the activity id
– Marcelo Augusto
@Cayodasilvalima As for the exact structure of the table, the relevant data are the same. I added an example of the populated tables that matches the expected result. See if it’s enough. Quan
– Marcelo Augusto
@Marceloaugusto your question is not clear enough. Post the way you are doing.
– Jorge.M