- nner Join
DB::table('admin') ->join('contacts', 'admin.id', '=', 'contacts.user_id') ->join('orders', 'admin.id', '=', 'orders.user_id') ->select('users.id', 'contacts.phone', 'orders.price') ->get();
- Left Join / Right Join
$users = DB::table('admin') ->leftJoin('posts', 'admin.id', '=', 'posts.admin_id') ->get();
$users = DB::table('admin') ->rightJoin('posts', 'admin.id', '=', 'posts.admin_id') ->get(); - Cross Join
$user = DB::table('sizes') ->crossJoin('colours') ->get();
- Advanced Join
DB::table('admin') ->join('contacts', function ($join) { $join->on('admin.id', '=', 'contacts.admin_id')->orOn(...); }) ->get();
- Sub-Query Joins
$admin = DB::table('admin') ->joinSub($latestPosts, '
Tuesday, March 10, 2020
Laravel join query examples
Subscribe to:
Post Comments (Atom)
-
Composer is a major part of the Laravel MVC Framework, but it also exists without Laravel. In fact you could use it in any project. This a...
-
How to Answer Technical Questions Like a Pro Answering technical interview questions is all about showing off your problem-solving skills an...
-
Vuetify is a popular UI framework for Vue apps. In this article, we’ll look at how to work with the Vuetify framework. Color Picker Inputs W...
No comments:
Post a Comment