I am trying to make an inner join on two tables to get data. and it worked however when I search to get date from the table. I get an error saying
Integrity constraint violation: 1052 Column 'created_at' in where clause
is ambiguous, query was: SELECT COUNT(*) FROM `sales_flat_order` AS
`main_table`
INNER JOIN `sales_flat_order_item` ON main_table.store_id =
sales_flat_order_item.store_id WHERE (`created_at` >= '2017-04-01'
This is my code
$collection = Mage::getModel('sales/order')->getCollection();
$collection->addFieldToFilter('created_at');
$collection->getSelect()->join("sales_flat_order_item",
"main_table.store_id = sales_flat_order_item.store_id",
array('name','sku','order_id','quantity'));
2
Answers
Solved it.
You can try something like this
But your join looks weird maybe it would be better to use sales_flat_order.entity_id = sales_flat_order_item.order_id then store_id
What exactly do you try to get by that select?
Please, describe your task.