2
I have a jig table as follows:
| materia | provaID | matricula | questao | resposta |
matematica 303 211834 quest1 A
matematica 303 211834 quest2 C
matematica 303 211834 quest3 B
matematica 303 211834 quest4 D
matematica 304 211834 quest1 C
matematica 304 211834 quest2 A
matematica 303 741431 quest1 B
matematica 303 741431 quest2 D
matematica 303 741431 quest3 C
matematica 303 741431 quest4 E
The "proof" table looks like this:
| id | materia |
303 matematica
304 matematica
What I need is to relate the two tables, but list only the "answers" of the last "proof" but of each matricule thus staying:
| materia | provaID | matricula | questao | resposta |
**Ultimo desse aluno** matematica 304 211834 quest1 C
**Ultimo desse aluno** matematica 304 211834 quest2 A
**Ultimo desse aluno** matematica 303 741431 quest1 B
**Ultimo desse aluno** matematica 303 741431 quest2 D
**Ultimo desse aluno** matematica 303 741431 quest3 C
**Ultimo desse aluno** matematica 303 741431 quest4 E
That post /questions/175280/como-montar-um-select-para-retornar-a-ultima-altera%C3%A7%C3%a3o-de-status-de-every-id did not help me because it returns ONE row of each ID, I need it to return all the LAST lines of each matricule, getting as above.
See, this code returns to me part of what I need:
$gabaritoByAluno = $db->prepare("SELECT gabarito.*, prova.* FROM gabarito INNER JOIN prova ON (gabarito.provaID != prova.id) WHERE gabarito.materia = ? AND gabarito.matricula = ?");
$gabaritoByAluno->execute(array("AUTORIDADE ESPIRITUAL", "218113"));
while ($dadosByAlunos = $gabaritoByAluno->fetch()) {
echo $dadosByAlunos['questao'] . '<br>';
}
it returns me all questions, I want to return only the last questions that were quest1 and quest2 of provaID 304
Thank you very much, that solved my question perfectly, so I love this forum.
– José Roberto Juliana