saynotojava Posted April 23, 2014 Share Posted April 23, 2014 Let say i have five values in this structure: Student Score John 5 Johhy 4 Johnny 3 Jon 1 Job 2 And i want to find a value which have biggest number,in this case John. How do i do that? Quote Link to comment https://forums.phpfreaks.com/topic/287969-finding-a-biggest-number-in-mysql-table/ Share on other sites More sharing options...
cyberRobot Posted April 23, 2014 Share Posted April 23, 2014 Have you tried using MySQL's MAX() function? https://dev.mysql.com/doc/refman/5.0/en/example-maximum-column.html Quote Link to comment https://forums.phpfreaks.com/topic/287969-finding-a-biggest-number-in-mysql-table/#findComment-1477070 Share on other sites More sharing options...
ginerjm Posted April 23, 2014 Share Posted April 23, 2014 You do a little research on how to write sql statements. Looking for the largest value will involve using the sql 'max' function - try looking that up and then you can write your own code. Quote Link to comment https://forums.phpfreaks.com/topic/287969-finding-a-biggest-number-in-mysql-table/#findComment-1477071 Share on other sites More sharing options...
saynotojava Posted May 3, 2014 Author Share Posted May 3, 2014 Ok i found a proper query: SELECT MAX(POSITION) but it seems something is bugged here: ,when it reach number 10(i set a counter +1 on each new entry),for some reason it output number 9 as biggest number,not 10.And another thing,i have query to order by that column where i stored those numbers,but number 10 it is not last,for some reason it is sorted right after 1. Quote Link to comment https://forums.phpfreaks.com/topic/287969-finding-a-biggest-number-in-mysql-table/#findComment-1478113 Share on other sites More sharing options...
Solution saynotojava Posted May 4, 2014 Author Solution Share Posted May 4, 2014 Nevermind,had to set column as INT to make it work. Quote Link to comment https://forums.phpfreaks.com/topic/287969-finding-a-biggest-number-in-mysql-table/#findComment-1478140 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.