How to do a string concatenation with values from a database?

2

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

| id | value

| 1 | value1 |

| 2 | value2 |

| 3 | value3 |

To show the following result: value1, value2, value3

I'm using PHP + MySQL.

    
asked by anonymous 10.10.2015 / 05:21

1 answer

3

Just use the GROUP_CONCAT function. of MySQL.

SELECT GROUP_CONCAT(campo SEPARATOR ', ')
FROM tabela;
    
10.10.2015 / 05:28