2016-12-02 31 views

回答

4

你的查询应该是这样的:

DB::table('table') 
    ->where(function($q) use ($value, $value2) { 
     $q->where('column', $value) 
     ->orWhere('column', $value2); 
    }) 
    ->where('column2', 'like', '%'.%value3.'%') 
    ->get(); 

如果你有多个值,你可以把它们放到一个简单的数组中,并使用whereIn()

DB::table('table') 
    ->whereIn('column', $valuesArray) 
    ->where('column2', 'like', '%'.%value3.'%') 
    ->get(); 
0

可以将此根据做,使所需的查询

 DB::table('table_name') 
     ->where('column', 'value1') 
     ->orWhere('column', 'value2') 
     ->where('column2', 'like', '%value3%'); 
+0

不会产生分组的表达,而是会在查询,而括号中添加或条件 –