Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

whodoes's avatar

Querying from table using Query Builder

Ok here's the thing both are working just want to know which is more ideal on Query Buillder Doing a subquery or Joining the table?

       DB::raw('(SELECT Name FROM client_types WHERE client_types.id = taxonomy.Type ) AS Type'),                                   
         DB::raw('(CASE WHEN  taxonomy.isVerified = "0" THEN "UNVERIFIED"
                                    WHEN  taxonomy.isVerified = "1" THEN "VERIFIED"
                                    ELSE "UNVERIFIED" 
                                    END) AS Verification'))                                    
                    ->leftJoin('taxonomies as taxonomy', 'taxonomy_pivot.TaxonomyId','=','taxonomy.TaxonomyId');```

also what are the pointers to consider when to Join a table or create a subquery
0 likes
1 reply

Please or to participate in this conversation.