MySQL评分系统-查找评分 [英] MySQL Rating System - Find Rating
问题描述
我正在尝试通过用户给出的最佳评分来对水果类型"进行评分.
I'm trying to rate Types of Fruit by the best possible rating given by users.
我有一个名为Ratings的Fruit表,用于通过以下信息提交评分
I have a Fruit table called Ratings just for submitting ratings with the following Information
Fruit_id int
From_ID int
Rating int
现在我正在尝试运行如下所示的SQL命令
now I'm trying to run a SQL command like the following
select From_ID, AVG(Rating) AS Rating FROM Ratings Group BY `Fruit_ID` ORDER by Rating DESC
但是,如果我得到1个将水果的苹果评级为5的用户,然后又有1000个用户将橙色的评级为4的用户,则苹果突然被认为更好.
This works however, if i get 1 user who rates a fruit an apple a 5, and then 1000 users who rate an orange a 4 the apple is suddenly considered better.
我该如何考虑投票数,以确保投票得最多和得票最多?
How can i take number of votes into account, to ensure that the most voted along with best is first.
推荐答案
为什么不只是选择票数并将其显示给用户.因此,是的,一个苹果以1票对5票将是只有1票的5票.这将为用户提供一种简单的方法来查看给定评级的受欢迎程度".
Why not just select the number of votes and display that to the user. So yes, 1 vote of 5 for an apple would be an overall 5 BUT with only 1 vote. This would give the users a simple way to see how "popular" a given rating is.
如果我没有记错的话,这就是当今大多数五星级评级系统在网上工作的方式.
This is how most of the fivestar rating systems work on the net today if I am not mistaken.
祝你好运!
尼克
这篇关于MySQL评分系统-查找评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!