我有MySQL Query我想写这个查询zend 2.
(*p)[0]
在zend 2 am尝试这样写但是
select billsec,call_status,Count(*) from (select billsec,
if(ANSWERED_NUM is Null, 'Missed','Answered') call_status from cust_info
where billsec in (SELECT id FROM `users` WHERE `account_id` = 452 AND `added_by` = 20694 AND `status` = 'active'))a
group by a.billsec,a.call_status
何时打印此查询输出如下:
$adapter = $this->getAdapter();
$resultset = $this->select( function( Select $select ) use ( $request, $adapter ) {
$sub1 = new Select( 'users' );
$sub1->columns( array( 'id' ) );
$sub1->where( array( 'account_id' => '452','added_by' => '20694','status' => 'active' ) );
$sub2 = new Select( 'cust_info' );
$sub2->columns(array("id","billsec", "if(ANSWERED_NUM is Null, 'Missed','Answered')"=>"call_status"));
$sub2->where('billsec IN(?)', new \Zend\Db\Sql\Expression( '?', array( $sub1 ) ));
var_dump( $sub2->getSqlString( $adapter->getPlatform() ) );die();
});
这里无法写入IN条件查询,提前谢谢。