我在每个表中有 2 条记录。当我在下面的查询中尝试这个
$result = DB::table('table1')
->join('table2','table1.user_id','=', 'table2.user_id')
->join('table3','table1.user_id','=', 'table3.user_id')
->join('table4','table1.user_id','=', 'table4.user_id')
->select('table1.*','table2.email','table3.*','table4.*')
->get();
我仅从最后一个表中获得了重复的数据,而且我无法从前三个表中获取数据
我需要这样的输出
--------------------------------
id email user_id
--------------------------------
1 aaa@test.com 40
2 bbb@test.com 40
1 ccc@test.com 40
2 ddd@test.com 40
1 eee@test.com 40
2 fff@test.com 40
1 ggg@test.com 40
2 hhh@test.com 40
--------------------------------