0

I need to convert this query into laravel query builder

select * from employee where(( age = 25 and salary = 20000) or (age =30 and salary = 30000))
1
  • what is your current attempt? Commented Aug 14, 2018 at 6:07

2 Answers 2

1

If you want to group where clauses you can nest them inside closures:

DB::table('employee')
    ->where(function ($query) {
        $query->where('age', 25)->where('salary', 20000);
    })
    ->orWHere(function ($query) {
        $query->where('age', 30)->where('salary', 30000);
    })
    ->get();

For more information have a look at Parameter Grouping in the documentation.

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

1 Comment

can you please give me a reference or documentation link for this?
0

Can you try this,

$data = Model::where([["age", "25"],["salary", "20000"]])
    ->orWhere([["age", "30"],["salary", "30000"]])
    ->get();

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.