Laravel Join With AND/OR Condition.


Example Query.

Select * from abc_tbl 
inner join xyz_tbl on anb_tbl.id = xyz_tbl.userId AND anb_tbl.otherid = xyz_tbl.otherid

User Below Snippets.

$query_que = \DB::table('abc_tbl');

$query_que->join('xyz_tbl', function($join) {
            $join->on('abc_tbl.id', '=', 'xyz_tbl.userId');
            $join->on('anb_tbl.otherid', '=', 'xyz_tbl.otherid');
});


No comments:

Post a Comment