I have a thread, and different users rating a movie in 3 different types.
Say i have thread 22, and different types=movie.quality, movie.story and movie.imdb
so the structure of the rating table looks like this:
| ID | thread_id | user_id | type | value
| 12 | 22 | 2 | 'movie.imdb' | 8.5
| 23 | 22 | 4 | 'movie.imdb' | 7.5
| 42 | 22 | 5 | 'movie.story' | 8.5
| 56 | 22 | 6 | 'movie.quality' | 8.5
| 76 | 22 | 6 | 'movie.imdb' | 7.53
as a result of my query, i want to get the average pro id and type, something like
array(thread_id=22 => array(
type=>movie.imdb => average=>8.2),
type=>movie.story => average=>8.8),
type=>movie.quality => average=>8.1))
How can i structure this query?
you can do group by thread_id,type and can take AVG of value
now from the output of this query you can select based on the
thread_idin your code to make/form the array .. or more precisely array or array ..