Laravel 5: How to Join two different tables with WHERE condition

The query builder may also be used to write join statements.

To perform a basic "join", you may use the join method on a query builder instance.

You can join to multiple tables in a single query with Where condition:


  $pandl = DB::table('pandls')

            ->join('accounts', 'pandls.acc_id', '=', 'accounts.id')

            ->join('categories', 'pandls.cat_id', '=', 'categories.id')

            ->select('pandls.*', 'accounts.name', 'categories.cat_name')

            ->where('pl_type', 1)

            ->get();

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...