MDanz Posted March 16, 2011 Share Posted March 16, 2011 i tried this but it doesn't work. rating is a column with integer type. it is returning the wrong row with the lowest rating. how do i get the the highest rating(integer) in the WHERE clause? $getrest = mysql_query("SELECT * FROM block WHERE sid='505' ORDER BY 'rating' DESC LIMIT 1") or die(mysql_error()); while($row=mysql_fetch_assoc($getrest)) { $name= $row['name']; } echo $name; Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/ Share on other sites More sharing options...
Maq Posted March 16, 2011 Share Posted March 16, 2011 That looks correct. Are you sure this clause isn't effecting the result? WHERE sid='505' Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/#findComment-1188210 Share on other sites More sharing options...
MDanz Posted March 16, 2011 Author Share Posted March 16, 2011 this is weird i have two rows.. name sid rating f 505 2 e 505 5 with that query it keeps on returning f? i need the sid='505' in the where clause . Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/#findComment-1188213 Share on other sites More sharing options...
MDanz Posted March 16, 2011 Author Share Posted March 16, 2011 nvm.. i had to put the echo in the while loop Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/#findComment-1188215 Share on other sites More sharing options...
Maq Posted March 16, 2011 Share Posted March 16, 2011 You're gett nevermind.. i had to put the echo in the while loop Nevermind for your last post, or nevermind it's working? Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/#findComment-1188265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.