David,

Your question is a little bit unclear.
First, if it is rank, you do not need decimal, but integer (tinyint will
do it). Then you need a little bit of statistics to rank the picture
against the others, so, anytime each picture is ranked, you have to run
the statistics and update the table ("update images set rating=... where
image_id=...").
Then, in order to post the rank, just extract max(rating) (something like
"select max(rating) as ... from images") and then extract the rank of the
image ("select decimal from images where image_id=...") and you'll have
what you need.

Hope this helps and I did not write to many stupid things:)

Mihai

On Fri, 9 Aug 2002, David Balatero wrote:

> I have a MySQL table called images, each with a rating from 1-10. The column is a 
>decimal(10,2). For simplicity's sake, let's say i have the following:
>
> CREATE TABLE images (
>   image_id int not null auto_increment,
>   image_path varchar(255) not null,
>   rating decimal(10,2) not null,
>   primary key(image_id)
> );
>
>
> What I'm looking to do is be able to pull from the database the ranked position each 
>image is in. I.e. "this image is ranked 70 out of 121"
>
> Any suggestions on a MySQL query that could do this?
>
> Thanks,
> David Balatero
> [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to