Search code examples
phpmysqlrating

Calculations in mysql statement for rating


I want order a selection of items by the rating. There are 2 fields: rateup and ratedown. I use these fields to calculate a number and order the selection on that number. Can that be done in mysql? I have a querylike this, but this doesn't work:

SELECT * FROM table ORDER BY (((9/rateup+ratedown)*rateup)+1) DESC

How can I make this work or is this impossible?


Solution

  • Select *, (((9/rateup+ratedown)*rateup)+1) As Ord from Table WHERE published = 1 Order By Ord Desc
    

    added Where Clause as requested.