Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel join

Inner Join 	: ->join('contacts', 'users.id', '=', 'contacts.user_id')
Left Join 	: ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
Right Join 	: ->rightJoin('posts', 'users.id', '=', 'posts.user_id')
Cross Join 	: ->crossJoin('colors')

Advance Queries : 
----------------- 
 		->join('contacts', function ($join) {
            $join->on('users.id', '=', 'contacts.user_id')
                 ->where('contacts.user_id', '>', 5);
        })
  
Comment

laravel join

$users = DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.*', 'contacts.phone', 'orders.price')
            ->get();
Comment

join in laravel eloquent

 $customer = DB::table('customers')
                ->join('shops', 'customers.shop_id', '=', 'shops.shop_id')
                ->where('customer_contact', $contact_no)
                ->get();
Comment

join in laravel

$subCategories = Subcategory::join('categories', 'subcategories.category_id', '=', 'categories.id')
                              ->select('subcategories.*', 'categories.name AS cname')
                              ->orderBy('id', 'desc')
                              ->get();
Comment

how to use join in laravel 5.4

DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.id', 'contacts.phone', 'orders.price')
            ->get();
Comment

laravel join

$latestPosts = DB::table('posts')
                   ->select('user_id', DB::raw('MAX(created_at) as last_post_created_at'))
                   ->where('is_published', true)
                   ->groupBy('user_id');

$users = DB::table('users')
        ->joinSub($latestPosts, 'latest_posts', function ($join) {
            $join->on('users.id', '=', 'latest_posts.user_id');
        })->get();
Comment

laravel outer join

->join('answers as answers', 'responses.answer_id', '=', 'answers.id', 'left outer')
Comment

laravel join

$query = DB::table('posts')
            ->select('posts.*',
                    'subcategories.subcategory_title_en',
                    'subcategories.subcategory_title_bn',
                    'categories.category_title_en',
                    'categories.category_title_bn',
                    'users.*',
                    'postimages.postimage_thumbnail'
                    )
            ->join('subcategories', 'subcategories.subcategory_id', '=', 'posts.subcategory_id')
            ->join('categories', 'categories.category_id', '=', 'subcategories.parent_category_id')
            ->join('users', 'users.id', '=', 'posts.user_id')
            ->join('postimages', 'postimages.post_id', '=', 'posts.post_id')->groupBy('posts.post_id');
Comment

PREVIOUS NEXT
Code Example
Php :: Delete a single record in laravel 5 
Php :: laravel blade @auth 
Php :: Create a table with PHP in html 
Php :: softDelete laravel8 
Php :: session() in lumen 
Php :: job with queue name in laravel 
Php :: laravel Auth::logoutOtherDevices 
Php :: pmxi_gallery_image 
Php :: php artisan add row in table 
Php :: jquery greater than or equal to 
Php :: Advanced Custom Fields get sub field image 
Php :: how to check path laravel 
Php :: php version command linux 
Php :: laravel vue browser cache auto clear 
Php :: force https redirect php s 
Php :: get users other than specific role laravel role spatie 
Php :: laravel Form::hidden 
Php :: laravel imap - Get message attachments 
Php :: convert php array to javascript json laravel 
Php :: move img to public folder in laravel 
Php :: php mysql prepared statements 
Php :: dd php 
Php :: sort php 
Php :: alert message in blade template with() 
Php :: wp+get tags for custom post type 
Php :: laravel array in lang 
Php :: download file laravel s3 
Php :: session value not removed php 
Php :: laravel belongstomany prevent duplicates attach 
Php :: php select using prepared statements 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =