Friday, 6 May 2011

GroupConcat in MySql directly gives the output in required format as string

Language is column name and CountryLanguage is table name

English
Hindi
Punjabi
Chinese

SELECT GROUP_CONCAT(Language) As Languages FROM CountryLanguage;

Output will be:

English,Hindi,Punjabi,Chinese

SELECT GROUP_CONCAT(Language SEPARATOR '-') As Languages FROM CountryLanguage;
Output will be:


English-Hindi-Punjabi-Chinese

No comments:

Post a Comment