I have a table with a structure like:
| id | textfield | text_group | 
| 1  | yes       | 123        | 
| 2  | y         | 123        | 
| 3  | no        | abc        | 
| 4  | n         | abc        | 
I'd like to return all records, but such that I get:
| colA  | text_group | 
| yes y | 123        |
| no n  | abc        |
Is this possible simply with a query, or will I need to use some programming to format it as such? I would have done a group by, but then I lose the information in result ColA
The group_concat aggregate function should do the trick:
SELECT   group_concat (textfield SEPARATOR ' ') AS colA, text_group
FROM     my_table
GROUP BY text_group
                        Use GROUP_CONCAT :
SELECT text_group
     , GROUP_CONCAT(textfield SEPARATOR ' ') AS colA
FROM table
GROUP BY text_group
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With