Example of what I have col1 col2 col3 246 247 257 283 01 04 what I would like to do col1 col2 col3 246 247 246,247 257 260 257,258,259,260 01 04 01,02,03,04 what I have tried SELECT master,start,end, end-start as number, concat(start+1,',') as numbercombine FROM build LIMIT 20; SELECT master,start,end, if( between start and end,floor(1 + rand() * end)) as number FROM buildLIMIT 20;