GROUP_CONCAT function in Mysql

by Rekha 2010-10-01 10:57:23

GROUP_CONCAT function in Mysql



GROUP_CONCAT() function is used to concatenate column values into a single string. Note that this function will not count null values. This is very useful group by function if you need records from database with multiple rows in single string with specified seperator(e.g. Comma seperated).

Example:

Table tbl_users have 4 records in column "name".
- Hariharan
- Harish
- Haripranav
- Prabhu

SELECT name FROM tbl_users;
OutPut:
- Hariharan
- Harish
- Haripranav
- Prabhu

SELECT GROUP_CONCAT(name) FROM tbl_users;
Output:
Hariharan,Harish,Haripranav,Prabhu

Tagged in:

949
like
0
dislike
0
mail
flag

You must LOGIN to add comments