View Single Post
Old 01-15-2008, 04:52 PM   #9 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

In that case, I would use a query like the following:

PHP Code:
$web "SELECT tuto_id, rate FROM tuto ORDER BY rate DESC LIMIT 1"
This would select 'tuto_id' and 'rate' from the 'rate' table. It then sorts them by 'rate' in descending order (ie, highest first), then limits the results to 1. That way, you should only end up with 1 row, the one with the highest rating, containing the tuto_id and rate values.

Note: No-one has ever mistaken me for an SQL expert so I don't know if my query above is the "right" way to do it, but if it's wrong I'm sure someone else here can improve it

Alan.
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote