I’m looking for a way to join 3 Data Tables.
table a ------- a_id b_id a_val table b -------- b_id c_id b_val table c -------- c_id c_val
Laravel Query;
$join = DB::table('a')->join('b', 'b.b_id', 'a.b_id')->get();
How to fetch data from table ‘c’ by applying a query on table ‘a’?
i’m new to Laravel.
Advertisement
Answer
Basically, it is not as much related to laravel it needs knowledge of the database. You can join 3 tables like this.
$join = DB::table('a')->join('b', 'b.b_id', 'a.b_id')->join('c','b.c_id','c.c_id')->select('c.c_id','c.c_cval')->get();