Welcome Guest, Not a member yet? Register   Sign In
retrieve average rating on a join
#1

(This post was last modified: 01-18-2022, 02:08 AM by remesses_thegreat.)

Good Day 

I need help with result. I have a model that returns all business branches. 
I would like to join an additional table called Ratings and return the average rating for each company.

Does anyone have a simple script i can use. What's the best practice to achieve this.

Thanks in advance


PHP Code:
function getAllBranches()
    {
        $db      = \Config\Database::connect();
        $builder $db->table('branches');
        $builder->join('companies''companies.id = branches.companyId');
        $builder->join('businessprofile''businessprofile.companyId = branches.companyId'); 
        
        $builder
->where('paymentstatus''active');
        
        $query 
$builder->get();
        
        
return $query->getResult();
    
Reply


Messages In This Thread
retrieve average rating on a join - by remesses_thegreat - 01-18-2022, 02:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB