-8

How do I say WHERE (a=1 and b=1) or (c=1 and d=1)

For more complicated queries am I supposed to use raw SQL?

  • For seriously complicated queries I would use compiled sql, but that's just me. By the way please read on http://stackoverflow.com/tour – DeDee Sep 03 '15 at 12:05
  • possible duplicate of [MySQL select query with multiple conditions](http://stackoverflow.com/questions/16249731/mysql-select-query-with-multiple-conditions) – Syed mohamed aladeen Sep 03 '15 at 12:07
  • @syedmohamed I think he wants to express the query with Eloquent, rather than mySql. – Amarnasan Sep 03 '15 at 12:10
  • Possible duplicate of http://stackoverflow.com/questions/19325312/laravel-eloquent-multiple-where-clause-query – Amarnasan Sep 03 '15 at 12:13

2 Answers2

2

Try this: http://laravel.com/docs/5.1/queries#advanced-where-clauses

   DB::table('your_table')
    ->where(function($query)
    {
        $query->where('a', 1) ->where('b', 1);
    })
    ->orWhere(function($query)
    {
        $query->where('c', 1)->where('d', 1);
    })
    ->get();
-1

@esmail please try to study then,wrote comment.You can definitely do this like that code

->where(function($query)
        {
                $query->where('a', 1)
                ->where('b', 1);
        })
Imtiaz Pabel
  • 5,307
  • 1
  • 19
  • 24