combining results of two select objects Zend\Db\sql\sql

£可爱£侵袭症+ 提交于 2019-12-12 01:39:12

问题


I know the way to combine two select statments would look like this:

 SELECT tableA.Id
 FROM tableB 
 INNER JOIN tableA ON [tableB].Id = tableA.Owner

 UNION

 SELECT tableA.Id, tableA.Name
 FROM [tableC] 
 RIGHT OUTER JOIN tableA ON [tableC].tableAId =  tableA.Id

But how would it be if I'm using sql object?

   $sql = new Sql($adapter);
   $select = $sql->select();
   $select ->from(tableA);
   $select ->join(...)

Any help would be much appreciated. Thanks in advance


回答1:


ZF2 does have combine that works as union -

$select1->combine($select2);

I hope its helps someone.



来源:https://stackoverflow.com/questions/23346029/combining-results-of-two-select-objects-zend-db-sql-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!