title: How to merge data with same id in PHP?
body: <p>My select returns values like this:
  <a href="https://i.stack.imgur.com/xoSO6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xoSO6.png" alt="enter image description here"></a></p>
  
  <p>It can merge the two lines into one? If so, it is possible in php, or Tsql?<br>
  Something like:
  <a href="https://i.stack.imgur.com/mUpWo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mUpWo.png" alt="enter image description here"></a></p>
  
  <p>This is my select:  </p>
  
  <pre><code>           SELECT TRM_ID_TURMA
                   , TRM_HORA_INICIO
                   , TRM_HORA_FIM
                   , TRM_DIA
                   , TRM_VAGAS
                   , MGN_NOME
                   , PROF.USU_NOME AS PROFESSOR
                   , ALU_MATRICULA
                   , USU.USU_NOME NOMEALUNO
                FROM [MGB].[dbo].[TB_TURMA]
               INNER JOIN TB_USUARIO PROF ON PROF.USU_ID_USUARIO = TRM_ID_PROFESSOR
               INNER JOIN TB_NIVEL_TURMA ON NTR_ID_NIVEL_TURMA = TRM_ID_NIVEL
               INNER JOIN TB_MGB_NIVEL ON MGN_ID_MGB_NIVEL = NTR_ID_MGB_NIVEL
               INNER JOIN TB_LOCAL ON LOC_ID_LOCAL = TRM_ID_LOCAL
                LEFT JOIN TB_TURMA_ALUNO ON TAL_ID_TURMA = TRM_ID_TURMA
                LEFT JOIN TB_ALUNO ON ALU_ID_ALUNO = TAL_ID_ALUNO
                LEFT JOIN TB_USUARIO USU ON USU.USU_ID_USUARIO = ALU_ID_USUARIO
               WHERE TRM_ID_ACADEMIA = 27
                 AND TRM_STATUS &gt;= 0
                 AND (TAL_STATUS IS NULL OR TAL_STATUS &gt;= 0)
               ORDER BY TRM_HORA_INICIO,  TRM_HORA_FIM, TRM_DIA, ALU_MATRICULA, NOMEALUNO
  </code></pre>