{"id":1647,"date":"2013-10-21T09:28:11","date_gmt":"2013-10-21T09:28:11","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=1647"},"modified":"2013-10-21T09:29:10","modified_gmt":"2013-10-21T09:29:10","slug":"mysql-group_concat","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=1647","title":{"rendered":"MySql Group_Concat"},"content":{"rendered":"<p>The result of GROUP_CONCAT is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024.<\/p>\n<p>This will cause\u00a0 data-destroying bugs in production. For this reason you should probably not use GROUP_CONCAT . At least you must set the value of group_concat_max_len to an insanely high value on every database server your application runs on.<\/p>\n<p>Like MAX or COUNT, GROUP_CONCAT is a MySQL aggregation function you can use whenever your query contains a GROUP BY. You can use it to retrieve a comma-separated list of all values in a given column within each group.<\/p>\n<p>[sql]<br \/>\nselect  client<br \/>\n,Month<br \/>\n,year<br \/>\n,Sum(Amount) as Amount_Total<br \/>\n,GROUP_CONCAT(Amount) as Amount_Detail<br \/>\n,GROUP_CONCAT(InvoiceNum) as Invoices<br \/>\nfrom mytable<br \/>\n group by Client<br \/>\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The result of GROUP_CONCAT is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. This will cause\u00a0 data-destroying bugs in production. For this reason you should probably not use GROUP_CONCAT . At least you must set the value of group_concat_max_len to an insanely high [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-mysql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1647"}],"version-history":[{"count":3,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1647\/revisions"}],"predecessor-version":[{"id":1650,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1647\/revisions\/1650"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}