数据库设置(MySQL的)用户提交的前5名和排序按热门程度
表:top_fives
id, uid, first, second, third, fourth, fifth, creation_date
1, 1, cheese, eggs, ham, bacon, ketchup, 2010-03-17
2, 2, mayonaise, cheese, ketchup, eggs, bacon, 2010-03-17
用户可以提交他们的前5某一主题的。现在我想根据受欢迎程度排序的前五名的总结。
每列都有自己的点值。列“第一”是奖励5分,“第二”四点,“第三”三个点,等等...
所以,在我的例子应该是这样的:
1 Cheese (9 points = 5 + 4 -> 1 time in 'first' column and 1 time in 'second' column)
2 Eggs (6 points)
3 Mayonaise (5 points)
4 Ketchup (4 points)
5 Bacon (3 points)
6 Ham (3 points)
什么是这种情况下最简单的解决方案(PHP)?
@Bundy:出于好奇,你试试我的查询吗? – 2010-03-18 11:25:14