lundi 25 juillet 2016

Laravel 4 - Select rows where count of rows in joined table greater than 0

I need to grab rows of users where rows of items exist. Here is my code so far: $users = DB::table('users') ->join('orders', 'orders.user_id', '=', 'users.id') ->join('items', 'items.user_id', '=', 'users.id'); How do I add a where condition that will only select users that have at least one item?

Aucun commentaire:

Enregistrer un commentaire