mysql comma delimited result  [ 644 views ]

Goal: select a quick comma delimited value for a column

The method is easy. In this example the result is a long string contains comma delimited list of the language names.

select GROUP_CONCAT(lng_name) as lngnames from languages;

the result something like this:

English,Afar,Abkhazian,Afrikaans,Amharic,Arabic,Assamese,Aymara,Azerbaijani,Bashkir ...

But the working buffer size is a weak point in this story. The correct way something like this:

SET SESSION group_concat_max_len = 1000000;
select GROUP_CONCAT(lng_name) as lngnames from languages;

So the result is hopefully the full length string… Don’t forget to check!

#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }