Is there a way to have more complex where clauses on an Mjoin?

Is there a way to have more complex where clauses on an Mjoin?

rw152rw152 Posts: 52Questions: 15Answers: 1

I'm finding that I need to do a whereIn, so something like:

->where('Business_EmployeeRole.CreatedByBusinessID',$businessesOwned,'IN')

where $busienssesOwned would be a string of id's like ('1','2','3'). When I do this, I get the error "SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near '@P1'."

Answers

  • rw152rw152 Posts: 52Questions: 15Answers: 1

    Sorry, I solved this pretty easily. You can just use a closure:

    ->where(function ($q) use ($businessesOwned) {
                            $q->where( 'Business_EmployeeRole.CreatedByBusinessID', $businessesOwned, 'IN', false );
                        })
    
Sign In or Register to comment.