有人可以告诉我吗?
如何在magento中编写此类查询 (多个条件在上)
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON (Customers.CustomerID=Orders.CustomerID and Orders.status = 1)
//我知道这种类型
$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')), 'main_table.foreign_id = table_alias.primary_key', array('table_alias.*'));
如何在JOIN中添加多个条件?
答案 0 :(得分:3)
我自己找到了答案,结果非常简单
$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')), 'main_table.foreign_id = table_alias.primary_key and table_alias.columnname = ".."' , array('table_alias.*'));