Magento2 – Using addFieldToFilter() with Conditions

databasefiltermagento2

I need to filter values based on and condition in my custom table

my tablename Testing

 +-------------+--------------------+--------------------+
 | customer_id | customergroup      | customeremails     |
 +-------------+--------------------+--------------------+

if customergroup and customeremails same means I dont add this value

so, I put this condition:

   $multiselectupdate =$multiselect->getCollection()
                                ->addFieldToFilter('customergroup', "'eq'=>$categoryname")
                                ->addFieldToFilter('customeremails',"'eq'=>$mail");

But, its not working for Suggest me How set And Condition in addFieldToFilter() method.

Best Answer

Try with below code,

$multiselectupdate =$multiselect->getCollection()
                                ->addFieldToFilter('customergroup', ['eq' => $categoryname])
                                ->addFieldToFilter('customeremails',['eq' => $mail]);
Related Topic