Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-2008, 02:27 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-19-2008, 02:37 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 Search this Thread
Search this Thread:

Advanced Search
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



All times are GMT. The time now is 12:53 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.