sql – Zend如何创建左连接

前端之家收集整理的这篇文章主要介绍了sql – Zend如何创建左连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何打开此左连接查询
select advertisercontest.*,advertiseraccount.advertiserid,advertiseraccount.companyname
from advertisercontest
left join advertiseraccount on advertiseraccount.loginid = advertisercontest.loginid 
where advertisercontest.golive is not NULL;

进入Zend的左连接?

解决方法

你可以这样做:
$db = Zend_Db_Table::getDefaultAdapter();

    $select = $db->select();
    $select->from('advertisercontest','*')
            ->joinLeft(
                    'advertiseraccount','advertiseraccount.loginid = advertisercontest.loginid',array('advertiseraccount.advertiserid','advertiseraccount.companyname')
                    )
            ->where('advertisercontest.golive is not NULL');;

    $result = $db->fetchAll($select);

    var_dump($result);

希望没关系.

猜你在找的MsSQL相关文章