{"id":950,"date":"2017-06-06T02:32:46","date_gmt":"2017-06-06T02:32:46","guid":{"rendered":"http:\/\/blog.silverterra.net\/?p=950"},"modified":"2017-06-06T02:32:46","modified_gmt":"2017-06-06T02:32:46","slug":"mysql-comma-delimited-result","status":"publish","type":"post","link":"https:\/\/blog.silverterra.net\/?p=950","title":{"rendered":"mysql comma delimited result"},"content":{"rendered":"<blockquote><p>Goal: select a quick comma delimited value for a column<\/p><\/blockquote>\n<p>The method is easy. In this example the result is a long string contains comma delimited list of the language names.<\/p>\n<pre data-enlighter-language=\"sql\" class=\"EnlighterJSRAW\">\r\nselect GROUP_CONCAT(lng_name) as lngnames from languages;\r\n<\/pre>\n<p>the result something like this:<\/p>\n<pre data-enlighter-language=\"raw\" class=\"EnlighterJSRAW\">\r\nEnglish,Afar,Abkhazian,Afrikaans,Amharic,Arabic,Assamese,Aymara,Azerbaijani,Bashkir ...\r\n<\/pre>\n<p>But the working buffer size is a weak point in this story. The correct way something like this:<\/p>\n<pre data-enlighter-language=\"sql\" class=\"EnlighterJSRAW\">\r\nSET SESSION group_concat_max_len = 1000000;\r\nselect GROUP_CONCAT(lng_name) as lngnames from languages;\r\n<\/pre>\n<p>So the result is hopefully the full length string&#8230; Don&#8217;t forget to check!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. the result something like this: But the working buffer size is a weak point in this story. The correct way something like this: So [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-950","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=950"}],"version-history":[{"count":1,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/950\/revisions"}],"predecessor-version":[{"id":951,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/950\/revisions\/951"}],"wp:attachment":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}