Shardj
Shardj

Reputation: 1969

Laravel select subquery

I'm rather stuck trying to figure out how I can run this as a single query from the database rather than fetching the results using one query then executing the other.

$query->whereIn('page_user_id', Staff::lists('staff_id'));

Thanks for the help

Upvotes: 1

Views: 208

Answers (1)

Lakhwinder Singh
Lakhwinder Singh

Reputation: 5582

$query->join('staff', 'staff.staff_id', '=', 'user.page_user_id')->get();

I think this will help. For reference http://laravel.com/docs/5.1/queries

Upvotes: 3

Related Questions