-3

我有一个 mysql 查询,但我不知道如何在 symfony2.0 中进行查询。

询问:

SELECT a.id, a.name,
FROM `ms_musiccategory` a
LEFT OUTER JOIN `ms_musiccategory` b ON a.parent_Id = b.id
ORDER BY coalesce( b.name, a.name ) , a.name
4

1 回答 1

-2
 $con = $this -> getEntityManager() -> getConnection();

 $st = $con -> prepare(' SELECT a.* FROM `tablename` a LEFT OUTER JOIN `tablename` b ON a.parent_Id = b.id ORDER BY coalesce( b.name, a.name ) , a.name');

 $st -> execute();

 $list = $st -> fetchAll();
于 2012-12-04T09:19:57.510 回答