I think it will be something like this. Give it a try.
$table = Your_DbTable_Class(); $select = $table->select() ->setIntegrityCheck(false) ->from(array('a' => 'students'), array( 'class' => 'class' , 'names' => new Zend_Db_Expr('GROUP_CONCAT(a.name)')) ) ->where( 'a.school = ?', 'ABC' ) ->group('a.class');
When I collect it, it gives me the following request:
SELECT `a`.`class`, GROUP_CONCAT(a.name) AS `names` FROM `students` AS `a` WHERE (a.school = 'ABC') GROUP BY `a`.`class`
Is this what you are looking for?
source share