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; Quote 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' Quote 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 . Quote 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 Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/230813-where-clause-highest-integer/#findComment-1188265 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.