vendredi 30 juillet 2021

How to add another table after joining multiple tables in Laravel?

I'm trying to achieve the following MySQL query with Laravel

SELECT a.*, b.*, c.* FROM table_1 a LEFT JOIN table_2 b ON a.b_id = b.id, table_3 c WHERE c.age > 21;

I know how to join tables in Laravel. But if you see my SQL query carefully you can find that there is another table just after the left join (without any join). This is where I'm stuck.

I tried the following code in Laravel, but didn't work.

DB::table(DB::raw('table_1 a, table_3 c'))
  ->select('a.*', 'b.*', 'c.*')
  ->leftJoin('table_2 b', 'a.b_id', '=', 'b.id')
  ->where('c.age', '>', 21)
  ->get();

Please help me out with the proper solution. Thanks in advance.

Note: Please ignore syntax error if any



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3C1xLIo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire