Say that I have a table in my database like the one below:
SELECT * FROM cms_releases;| Name | Latest stable release | Latest release date |
| Drupal | 7.7 | 2011-07-27 |
| Joomla | 1.7.0 | 2011-07-19 |
| Mambo | 4.6.5 | 2008-06-01 |
| WordPress | 3.2.1 | 2011-07-12[ |
| Xaraya | 1.2.1 | 2010-05-16 |
| Zikula | 1.2.7 | 2011-05-02 |
I want to query the above table and I want to get a coma separated sting that contains all the entries in the name column. I could write a PHP script that would iterate over the results of a simple SELECT query but I could also use the mysql GROUP_CONCAT function:
SELECT GROUP_CONCAT(name) as names FROM cms_releases ;And get the desired result:
Drupal, Joomla, Mambo, WordPress, Xaraya, Zikula
Comments
hi
hi
Wham bam thank you, ma'am, my
Wham bam thank you, ma'am, my questions are awnsered!
Post new comment