假設我有一個表:學生如何將GROUP_CONCAT與Zend Framework結合使用?
______________________________________________________
|id | name | school | class |
______________________________________________________
| 1 | John | ABC | C1 |
| 2 | Jack | ABC | C1 |
| 3 | Anna | ABC | C1 |
| 4 | Peter | DEF | D1 |
| 5 | Alex | ABC | C2 |
| 6 | Bryan | ABC | C2 |
| 7 | David | ABC | C2 |
| 8 | Cristian | DEF | D1 |
_______________________________________________________
使用此查詢:
SELECT a.class,GROUP_CONCAT(a.name) as names FROM students a WHERE a.school='ABC' GROUP BY a.class
給我這樣的結果:
____________________________
|class | names |
____________________________
| C1 | John, Jack, Anna |
| C2 | Alex, Bryan, David|
____________________________
我如何通過執行Zend框架此查詢使用Zend_Db_Table或Zend_Db_Select? 非常感謝!
感謝您的快速回復。我會嘗試的。 – 2011-06-13 12:37:52