In case anyone should run into this problem, but need it work on an id column that is not sequential, here is the solution.
In the below query test is the table name with the non sequential id column. And Dbname is optional if you already have your db selected.
SELECT
GROUP_CONCAT(id ORDER BY id ASC) AS "ids"
FROM
(
SELECT
@row := @row +1 AS rownum, id
FROM
(
SELECT @row :=0
) r, Dbname.test
) ranked
GROUP BY
FLOOR((rownum - 1) / 2);
If you have a table that looks like this:
id
1
2
3
4
10
15
17
18
20
21
23
25
32
55
105
1011
1012
1013
1014
1111
1112
1113
1114
1115
1116
1117
1118
1119
2001
2002
2003
The above query will give the results like this:
ids
1,2
3,4
10,15
17,18
20,21
23,25
32,55
105,1011
1012,1013
1014,1111
1112,1113
1114,1115
1116,1117
1118,1119
2001,2002
2003
And finally if you changed this line
FLOOR((rownum - 1) / 2);
to
FLOOR((rownum - 1) / 3);
The results would like this:
ids
1,2,3
4,10,15
17,18,20
21,23,25
32,55,105
1011,1012,1013
1014,1111,1112
1113,1114,1115
1116,1117,1118
1119,2001,2002
2003
Hope that helps someone.