jwk811 Posted February 12, 2007 Share Posted February 12, 2007 i need to retrieve the biggest number thats in an int column on my db.. how can i do that? Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/ Share on other sites More sharing options...
cmgmyr Posted February 12, 2007 Share Posted February 12, 2007 select max(yournum) as biggest from table Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/#findComment-182386 Share on other sites More sharing options...
giba Posted February 12, 2007 Share Posted February 12, 2007 What a surprise! I entered now to forum the same question! Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/#findComment-182387 Share on other sites More sharing options...
lachild Posted February 12, 2007 Share Posted February 12, 2007 You would add to the end of your call 'ORDER BY cell DESC LIMIT 1' As an example I have 1 table named 'Table1' with 2 cells 'Cell1' and 'Cell2' ------------------------------------- | Table 1 | ------------------------------------- | Cell1 | Cell2 | -------------------------------------- | Bob | 22 | | George | 33 | | William | 21 | -------------------------------------- To find the Highest number my SQL call would be the following "SELECT Cell2 FROM Table1 ORDER BY Cell2 DESC LIMIT 1;" would return '33' Hope that helps, Lachild Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/#findComment-182392 Share on other sites More sharing options...
lachild Posted February 12, 2007 Share Posted February 12, 2007 select max(yournum) as biggest from table LOL you beat me... But this answer is a little cleaner then mine.. Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/#findComment-182397 Share on other sites More sharing options...
jwk811 Posted February 12, 2007 Author Share Posted February 12, 2007 What a surprise! I entered now to forum the same question!LOL and thanks i got it now Quote Link to comment https://forums.phpfreaks.com/topic/38098-get-greatest-number-in-db/#findComment-182418 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.