How to concatenate strings with values from a database?

Asked

Viewed 31 times

2

I want to concatenate values from different records, for example, I have the table below:

| id | value |


| 1 | valor1 |

| 2 | valor2 |

| 3 | Valor3 |


To show the following result: value1, value2, Valor3

I’m using PHP + Mysql.

1 answer

3


Just use the function GROUP_CONCAT mysql.

SELECT GROUP_CONCAT(campo SEPARATOR ', ')
FROM tabela;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.