【问题标题】:How do I say WHERE (a=1 and b=1) or (c=1 and d=1)我怎么说 WHERE (a=1 and b=1) or (c=1 and d=1)
【发布时间】:2015-11-29 06:10:38
【问题描述】:

我怎么说 WHERE (a=1 and b=1) or (c=1 and d=1)

对于更复杂的查询,我应该使用原始 SQL 吗?

【问题讨论】:

标签: php laravel


【解决方案1】:

@esmail 那就请努力学习,写评论。你绝对可以像那个代码那样做

->where(function($query)
        {
                $query->where('a', 1)
                ->where('b', 1);
        })

【讨论】:

    【解决方案2】:

    试试这个: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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      相关资源
      最近更新 更多