Zend DB Left Join

I understand that Zend DB, Left Join SQL query returns NULL for the join column. It's true?

For instance:

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

Returns null for all vid ...

+4
source share
1 answer

The problem is that the vid column in your query refers to two tables, but obviously can only store one value in the result set. To fix the problem, create an alias for it, indicating explicitly which table to use:

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

Source: https://habr.com/ru/post/1486174/


All Articles