Sunday, 30 April 2023

Join two MySQL tables in different databases on the same server with Laravel Eloquent

 Model1::where('postID',$postID)

      ->join('database2.table2 as db2','Model1.id','=','db2.id')
      ->select(['Model1.*','db2.firstName','db2.lastName'])
      ->orderBy('score','desc')
      ->get();

No comments:

Post a Comment

Other post

1) The create() Method The  create()  method is a powerful and convenient way to store data in your Laravel application. It is typically use...