dongxun6458 2015-11-24 14:01
浏览 225
已采纳

如何在PHP中合并具有相同ID的数据?

My select returns values like this: enter image description here

It can merge the two lines into one? If so, it is possible in php, or Tsql?
Something like: enter image description here

This is my select:

           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 >= 0
               AND (TAL_STATUS IS NULL OR TAL_STATUS >= 0)
             ORDER BY TRM_HORA_INICIO,  TRM_HORA_FIM, TRM_DIA, ALU_MATRICULA, NOMEALUNO
  • 写回答

3条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 R语言数据分析的相关问题
      • ¥15 模型导入SP后贴图纹理只有一个,拆了四张UV的,怎么解决?
      • ¥15 检索带order by 非常慢
      • ¥20 python 爬虫 token 加密方式
      • ¥20 IAR环境报错reading CPU status failed
      • ¥20 Python如何读取指定播放设备的音频帧?
      • ¥15 用dnspy修改游戏数据报错
      • ¥15 关于unity打包成webgl后页面上不显示服务端接收到的数据的问题
      • ¥16 (大一)有偿 想学会 excel数据处理和分析🥹
      • ¥15 matlab导入工具箱提示:此类型的变量不支持使用点进行索引错误