Skip to content

Instantly share code, notes, and snippets.

@LeandroLS
Created June 24, 2017 17:51
Show Gist options
  • Save LeandroLS/1d5cfdd71843380ae630b1802bb499f0 to your computer and use it in GitHub Desktop.
Save LeandroLS/1d5cfdd71843380ae630b1802bb499f0 to your computer and use it in GitHub Desktop.
Post GROUP_CONCAT() no MYSQL
SELECT
GROUP_CONCAT(contas.nome) AS contas,
classificacao.nome AS classificacao
FROM
contas
INNER JOIN
classificacao ON classificacao.id = contas.id_classificacao
GROUP BY classificacao.nome;
+------------------------------------------------------------+---------------+
| contas | classificacao |
+------------------------------------------------------------+---------------+
| Conta de água,Conta de luz,Jogos da Steam | despesa |
| Rendimento de investimentos,Recebimento de aluguel,Salario | receita |
+------------------------------------------------------------+---------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment