SELECT GROUP_CONCAT( DISTINCT uid ORDER BY sorting ASC SEPARATOR ',' ) as uids FROM table WHERE .. GROUP BY field