简体   繁体   English

Zend DB左连接

[英]Zend DB Left Join

I realize that Zend DB, Left Join SQL query return NULL for the join column. 我意识到Zend DB,Left Join SQL查询为连接列返回NULL。 Is this true? 这是真的?

For example: 例如:

$selectmatchedtime = $this->dbo->select()
            ->from(array('v'=>'table1'))
            ->joinLeft(array('vc'=>'table2'),'vc.vid = v.vid');

Return null for all vid... 为所有视频返回null ...

The problem is that vid column in your query belongs to two tables, but obviously can store only a single value in the result set. 问题在于查询中的vid列属于两个表,但是显然只能在结果集中存储一个值。 To resolve the problem, make an alias for it, stating explicitly which table should be used: 要解决该问题,请为其创建别名,明确指出应使用哪个表:

$selectmatchedtime = $this->dbo->select()
            ->from(array('v'=>'table1'))
            ->joinLeft(array('vc'=>'table2'),'vc.vid = v.vid')
            ->columns(array('vid'=>'v.vid'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM