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

Hey Folks, It’s Worse Than We Thought — Claude’s Privacy Mess Just Got Bigger

  What started as a leak of shared Claude chats has turned into something much bigger — and much worse. The same thing is now happening with...