开发者

how to prepare subquery in zend framework

I want to prepare a subquery like this in zend framework:

select * from dept_view
where
(
   (select sum(开发者_如何学Gosal) from emp where emp_id IN (10,11))
   &
   dept_sal
)

any ideas ?

Thanks,


Something like this should work:

$subSelect = $db->select();
$subSelect->from('emp', array('SUM(sal)'))
  ->where('emp_id IN (?)', array(10,11));

$select = $db->select();
$select->from('dept_view')
 ->where($subSelect);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜