數據庫設置(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