join three tables

 


$result = DB::table('table1')

            ->join('table2', 'table1.column1', '=', 'table2.column1')

            ->join('table3', 'table1.column2', '=', 'table3.column2')

            ->select('table1.column1 as column1', 'table2.column2 as column2', 'table3.column3 as column3')

            ->get();




$result = DB::table('table1')
            ->join('table2', 'table1.column1', '=', 'table2.column1')
            ->join('table3', 'table1.column2', '=', 'table3.column2')
            ->select('table1.column1 as column1', 'table2.column2 as column2', 'table3.column3 as column3')
            ->get();



SELECT t1.column1 AS column1, t2.column2 AS column2, t3.column3 AS column3
FROM table1 AS t1
JOIN table2 AS t2 ON t1.column1 = t2.column1
JOIN table3 AS t3 ON t1.column2 = t3.column2;





















sql



No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...