Reputation: 14142
I have the following Collection in Magento :-
$this->addFieldToFilter(array('postcode', 'organisation_name'),array(
array('eq' => $postcode),
array('like' => $lastname. '%')
));
return $this;
This returns a query as follows:
SELECT `main_table`.`organisation_id`, `main_table`.`organisation_id`,
`main_table`.`organisation_type_id`, `main_table`.`organisation_name`, `main_table`.`street`,
`main_table`.`town`, `main_table`.`county`, `main_table`.`country`, `main_table`.`postcode` FROM
`organisation` AS `main_table` WHERE ((postcode = 'AA11AA')
OR (organisation_name LIKE 'jones%'))
LIMIT 1
How do I amend this so it becomes an AND rather than an OR in the SQL query returned?
Upvotes: 0
Views: 42
Reputation: 15206
Try it like this:
$this->addFieldToFilter('postcode',array('eq' => $postcode))
->addFieldToFilter('organisation_name',array('like' => $lastname. '%'))
Upvotes: 2