Hi all, I need some help ! I need to pull 6 records out of a table with the highest numbers first in desc order. Easy...however these numbers are stored like 7.886 or 8.9987 - What i need is to round them down or up in the SELECT query ! How would i do that ? SELECT * from numbertable ORDER BY NUMBERTABLE DESC ***WHERE DO I ROUND THE NUMBER ???** Thanks.
http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_round there you go but why do you need to round them? what's wrong with just sorting them as is
SELECT round(COLUM_NAME_HERE) from numbertable ORDER BY COLUMN_NAME_HERE DESC seriously dude.. show some initiative..
what output is it that you want? waht output ou get instead? are you sure it's a query error and not a script error? rn the query inside mysql and see what's the output... a more descriptive account of the problem will help more rather that just "it doesn't work"
SELECT * FROM rate_members LEFT JOIN pictures ON members.m_id=pictures.i_user WHERE i_status=2 AND i_rating > 2 AND m_type = 1 ORDER BY i_rating DESC Limit 6 PHP: lets say i echo $i_rating it would look like this - 7.87585 What i need is say 7.8 i.e two decimal places ! Where can i put the ROUND function in the SELECT query ?
don't use * you have to list out all the columns that you want to list out. for the i_rating column select ..... ,round(i_rating,2) from rate_members ......... Code (markup):