Jump to content

Sort mysql result by a different tables values


tail

Recommended Posts

I'm working on a script that shows game compiled in a MySQL database. I'm trying to sort them 3 different ways: newest, most popular, and highest rated.

 

The first two are easy because they are in the same table as the game information. However, the ratings are stored in a different table. I think this is possible to do using a join, but I don't know how to do that. The tables are set up as follows:

 

table `info`

| id | user_id | name | desc | category | plays | date_added |

 

table `rating`

| game_id | user_id | rating_value |

 

Is it possible to add up the rating values, then divide that by the number of ratings for the specific id, then sort the result by the highest rated game?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.