1

I need to use multiple WhereIn Clauses with OR in a query.. So I was doing it something like below... It is not working and I am getting an empty result

orWhereIn('cat', $array)
orWhereIn('cat_a', $array)
orWhereIn('child_a', $array)

is it possible? .. I have looked over the internet for solution but could find anything

I am using Laravel 4.2 .. thanks in advance

My Full Query

Note: if I use single whereIn clause.. it works absolutely fine..

$query = Product::query();
$query->orWhereIn('category_id', $ids);
$query->orWhereIn('category_id_2', $ids);
$query->orWhereIn('category_id_3', $ids);
$query->orderBy('price_for_sorting', 'ASC');
$products = $query->paginate(15);
8
  • Yes, it should work. Just make sure that if you have another where clause that's meant to be an AND, that you have your query nested properly.
    – aynber
    Feb 1, 2019 at 17:39
  • I am only using paginate() after this query Feb 1, 2019 at 17:46
  • Can you show your full query?
    – aynber
    Feb 1, 2019 at 17:46
  • i've edited my question @anyber Feb 1, 2019 at 17:50
  • If you use get() instead of paginate(), do you get the results?
    – aynber
    Feb 1, 2019 at 17:55

0

Your Answer

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

Browse other questions tagged or ask your own question.