0
DB::table('products')
->where('status', '=', 'published')
->where('sub_category', '=', 'grooming-wellness')
->where('sub_category', '=', 'beauty-care')
->get();

it doesn't work. it returns 0 data.

1
  • What is your goal? Commented Dec 11, 2019 at 10:38

1 Answer 1

4

I am assuming you want to check if a field has a particular value or another value. You can use whereIn to achieve this:

DB::table('products')
    ->where('status', '=', 'published')
    ->whereIn('sub_category', ['grooming-wellness', 'beauty-care'])
    ->get();

Laravel 6.x Docs - Query Builder - Where Clauses - Additional Where Clauses whereIn

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.