• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
avg and join, some help?

#1
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')
                    ->orderBy('gameNAME''ASC');
      $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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.