Complicated MySQL query?

Posted by Scott on Stack Overflow See other posts from Stack Overflow or by Scott
Published on 2010-05-22T22:15:57Z Indexed on 2010/05/22 22:20 UTC
Read the original article Hit count: 281

Filed under:
|

I have two tables:

RatingsTable that contains a ratingname and a bit whether it is a positive or negative rating:

Good 1
Bad 0
Fun 1
Boring 0

FeedbackTable that contains feedback on things...the person rating, the rating and the thing rated. The feedback can be determined if it's a positive or negative rating based on RatingsTable.

Jim Chicken Good
Jim Steak Bad
Ted Waterskiing Fun
Ted Hiking Fun
Nancy Hiking Boring

I am trying to write an efficient MySQL query for the following:

On a page, I want to display the the top 'things' that have the highest proportional positive ratings. I want to be sure that the items from the feedback table are unique...meaning, that if Jim has rated Chicken Good 20 times...it should only be counted once. At some point I will want to require a minimum number of ratings (at least 10) to be counted for this page as well. I'll want to to do the same for highest proportional negative ratings, but I am sure I can tweak the one for positive accordingly.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql-query