Reputation: 7
Laravel query builder for multiple whereIn() statements with or condition instead of deault and condition
$meetings = DB::table('googlesheet')->whereIn('rollnumber1',$qTXT)->whereIn('rollnumber2',$qTXT)->whereIn('rollnumber3',$qTXT)->whereIn('rollnumber4',$qTXT)->toSql();
Uses 'and' but I need 'or' condition
Upvotes: 1
Views: 11722
Reputation: 5082
You can add or
as the third parameter.
$meetings = DB::table('googlesheet')->whereIn('rollnumber1',$qTXT, 'or')->whereIn('rollnumber2',$qTXT, 'or')->whereIn('rollnumber3',$qTXT, 'or')->whereIn('rollnumber4',$qTXT, 'or')->toSql();
Or you can use orWhereIn()
$meetings = DB::table('googlesheet')->whereIn('rollnumber1',$qTXT)->orWhereIn('rollnumber2',$qTXT)->orWhereIn('rollnumber3',$qTXT)->orWhereIn('rollnumber4',$qTXT)->toSql();
Upvotes: 2