phpSensei Posted October 10, 2008 Share Posted October 10, 2008 Hi, Its been awhile since I have been coding in PHP, What I am trying to do is SELECT field1, field2, field3 FROM table ORDER BY SUM(field1,field2,field3) LIMTI 5 I have 3 fields in my table, all 3 fields are ratings like 1.2/10, or 3.2/10, I want to order the table by the best ratings. SO I want it to order by the 3 columns... I was thinking of adding all 3 fields and then order by who has the best overall ratings.. Thankyou for any help. Link to comment https://forums.phpfreaks.com/topic/127882-order-by-sum/ Share on other sites More sharing options...
discomatt Posted October 10, 2008 Share Posted October 10, 2008 Is the data stored as a varchar/text ('3.2/10') or as a decimal/float? (3.2) Link to comment https://forums.phpfreaks.com/topic/127882-order-by-sum/#findComment-662102 Share on other sites More sharing options...
phpSensei Posted October 10, 2008 Author Share Posted October 10, 2008 decimal/float Link to comment https://forums.phpfreaks.com/topic/127882-order-by-sum/#findComment-662107 Share on other sites More sharing options...
discomatt Posted October 10, 2008 Share Posted October 10, 2008 SELECT * FROM `table` ORDER BY (`field1`+`field2`+`field3`) DESC Link to comment https://forums.phpfreaks.com/topic/127882-order-by-sum/#findComment-662124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.