Welcome Guest, Not a member yet? Register   Sign In
avg and join, some help?

Hi! I'm new to the forums I search on the forum and nothing comes as results, or maybe I didn't put the correct words.
The problem is I'm doing a little app with CodeIgniter, is years ago that I touch PHP and CodeIgniter, and I'm relearning all again doing this little app.
In this app I'm doing a table to show a list of games and one column of that game table is a user ratings of the game that I try to select from a table where all the gameID, userID, ratingSCORE are stored. So I have to perform an AVG select from the column with the SCOREs.
I have this code.
PHP Code:
      $builder $db->table('games')
                    ->join('developers''developers.developerID = games.developerID')
                    ->join('publishers''publishers.publisherID = games.publisherID')
                    ->join("SELECT AVG(ratingSCORE) FROM ratings group by ratings.gameID"'ratings.gameID = games.gameID')
      $query $builder->get();
      return $query->getResultArray(); 
When I put the third join the sql didn't work, I read that a subquery can be done in that form in some slack answers.
Can someone, please, showme some light on this?
Thanks a lot.

Messages In This Thread
avg and join, some help? - by jolupa - 01-12-2020, 05:42 AM

Theme © iAndrew 2016 - Forum software by © MyBB