Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
Query and Sub Query Join in laravel

I want to first join sub category and subling and it should be sub query for join mastercategory

$users = DB::table('mastercategory')
->join('subcategory', 'mastercategory.idcategory', '=', 'subcategory.idcategory_mastercategory')
->join('subling', 'subcategory.idsubcategory', '=', 'subling.idsubcategory_subcategory')
->select('mastercategory.*', 'subcategory.*','subling.*')
->get();

I want view like this

Mobile and Access.
    1. Mobile
      a. IPhone
      b. Nokia
    2. Mobile Cover

I tried above query and model but i getting view like this

Mobile and Access.
    1. Mobile
      a. IPhone
      b. Nokia
Mobile and Access.              
    2. Mobile Cover
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try out this, I have used joinSub function instead of join it might work according to your needs.

$subcategoryWithSubling = DB::table('subcategory')
->join('subling', 'subcategory.idsubcategory', '=', 
'subling.idsubcategory_subcategory')
->select('subcategory.*','subling.*');

$users = DB::table('mastercategory')
->joinSub($subcategoryWithSubling, 'subcategory', function($join) {
    $join->on('mastercategory.idcategory', '=', 
    'subcategory.idcategory_mastercategory')
})->get()
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!