Unix Technical Forum

group_concat in batches of N

This is a discussion on group_concat in batches of N within the MySQL forums, part of the Database Server Software category; --> Hi, How can I query my table so that it returns a list of "group_concat"s grouping by N? E.g.: ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-20-2008, 06:56 PM
avilella
 
Posts: n/a
Default group_concat in batches of N

Hi,

How can I query my table so that it returns a list of "group_concat"s
grouping by N?

E.g.:

select group_concat(field) from t where t.field2="condition";

so that I get the results as, for example, group_concats of N=10:

248,876,3158,12183,12242,16472,18008,18496,20835,2 7812
27840,28939,28950,30867,31961,32759,33358,59819,59 833,91740
99376,105623,117618,117733,166576,184408,184424,28 5010,285021,289723
291332,304954,324694,324761,324791,331684,340550,3 73651,388878,401832

Cheers,

Albert.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-20-2008, 06:56 PM
Rik Wasmus
 
Posts: n/a
Default Re: group_concat in batches of N

On Mon, 19 May 2008 16:27:45 +0200, avilella <avilella@gmail.com> wrote:

> Hi,
>
> How can I query my table so that it returns a list of "group_concat"s
> grouping by N?
>
> E.g.:
>
> select group_concat(field) from t where t.field2="condition";
>
> so that I get the results as, for example, group_concats of N=10:
>
> 248,876,3158,12183,12242,16472,18008,18496,20835,2 7812
> 27840,28939,28950,30867,31961,32759,33358,59819,59 833,91740
> 99376,105623,117618,117733,166576,184408,184424,28 5010,285021,289723
> 291332,304954,324694,324761,324791,331684,340550,3 73651,388878,401832
>
> Cheers,


SET @var = -1;
SELECT GROUP_CONCAT(fld), FLOOR((@var := @var + 1)/ 10) AS grouper FROM
table GROUP BY grouper;
--
Rik Wasmus
....spamrun finished
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com