How to write UNION in Doctrine 2.0

后端 未结 4 922
清歌不尽
清歌不尽 2020-12-15 06:49

How to write this SQL query in Doctrine 2.0 (and fetch results)?

(SELECT \'group\' AS type, 
    CONCAT(u.firstname, \" \", u.surname) as fullname, 
    g.na         


        
4条回答
  •  伪装坚强ぢ
    2020-12-15 07:14

    $connection = $em->getConnection();
    $query = $connection->prepare("SELECT field1, field2 FROM table1 
                                    UNION
                                    SELECT field3, field4 FROM table2 
                                    UNION 
                                    SELECT field5, field6 FROM table3
                                    ");
    $query->execute();
    $result = $query->fetchAll();
    

提交回复
热议问题