Prioritizing a MySQL Query…

Started by Aquilo, August 14, 2003, 01:01:08 AM

Previous topic - Next topic

Aquilo

I was wondering if it's possible to Weight the ORDER BY request based on three conditions with different weights – I'm not sure how to explain it, here is what I was thinking about:
Quote
$requests = mysql_query("
   SELECT Name
   FROM Table
   ORDER BY `HitsIn` LOW_PRIORITY DESC,  `Rating` MEDIUM_PRIORITY DESC, `DownLoads` HIGH_PRIORITY DESC");

What I'm trying to do is list a bunch of scripts and since someone can cheat with click-ins I want it to have a lower percentage of the highest results and the same with the Rating system having it count just a little bit better and the most weight on the number of downloads. or would something like this be better with them all weighted the same?

is something like this possible??
Thanks Aquilo

Spaceman-Spiff

afaik, there's no such thing like this in sql
you can code the priority level in PHP, or add a column for: 'rank' and increment it everytime someone downloads or rates the file
example: if you want user rating to be higher priority than number of downloads, you can make
download: rank + 1
rating: rank + 3

but imo, it's better if you make the script able to sort based on all 3 columns

[Unknown]

Why not like this?

$requests = mysql_query("
   SELECT Name
   FROM Table
   ORDER BY  DownLoads * 3 + HitsIn * 2 + Rating DESC");

-[Unknown]

Advertisement: