I have a student table and a parent table. A student may be associated with up to three parents.
SELECT
a.idAluno,
a.matriculaAluno,
a.nomeAluno,
a.sexoAluno,
a.dataNascAluno,
b.id,
b.matricula,
b.cpf,
b.nome
FROM
alunos a
LEFT JOIN matriculas b
ON a.matriculaAluno = b.matricula
WHERE
a.status = 1 AND b.status = 1
GROUP by
b.cpf
The return is: I wish you would not repeat the same records from the first table. And I want the table matriculas to come in grouped search.
In other words, for each student record, the three records of the responsible person are grouped, since each student can have a maximum of 3 people.