4

I have below query

$customers = array(1,2);

$select = $connection->select()
->from(
        ['ce' => 'customer_entity'], ['entity_id', 'firstname', 'lastname', 'email'] // Select Only Required Fields
)
->where('ce.entity_id IN? ',$customers);
echo $select;
exit;

How to pass IN & OR condition?

2 Answers 2

16

You need to modify your where slightly. Replace:

->where('ce.entity_id IN? ',$customers);

With:

->where('ce.entity_id IN (?)', $customers);
3
  • Thanks @Raphael again. Do we any link for this where we can find all conditions with Match. Support for OR/And condition what to do?
    – Jackson
    Commented Nov 2, 2016 at 11:42
  • @AnkitShah I don't understand what you're asking. Using IN is always an OR condition. You can't do an AND condition on a primary key. Commented Nov 2, 2016 at 11:44
  • Hi @Raphael Ashish has given answer orWhere / andWhere
    – Jackson
    Commented Nov 3, 2016 at 1:18
2

FOR OR condition you can use :

->where(new Zend_Db_Expr("(CONDITION_1 OR (CONDITION_2 AND (CONDITION_3 OR CONDITION_4)))"));

OR you can use

->orWhere instead of ->where

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.