ted_chou12 Posted February 10, 2007 Share Posted February 10, 2007 i have a mysql table column storing purely figures: eg. number 1 3 5 6 2 How can you get the biggest number? so what I want the output to be is "6" since is the biggest number in all of the rows. Thanks Ted Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/ Share on other sites More sharing options...
redbullmarky Posted February 10, 2007 Share Posted February 10, 2007 SELECT * FROM mytable ORDER BY thefield DESC LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/#findComment-181377 Share on other sites More sharing options...
ted_chou12 Posted February 10, 2007 Author Share Posted February 10, 2007 Thanks redbullmarky, i think max is what I wish to use, however, it doesnt seem to work with DATE formats, can anyone help me out please? Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/#findComment-181379 Share on other sites More sharing options...
wildteen88 Posted February 10, 2007 Share Posted February 10, 2007 Then use redbullmarky's suggestion and use the ORDER BY clause. Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/#findComment-181380 Share on other sites More sharing options...
ted_chou12 Posted February 10, 2007 Author Share Posted February 10, 2007 okay, ill have a go with that Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/#findComment-181381 Share on other sites More sharing options...
AndyB Posted February 10, 2007 Share Posted February 10, 2007 ... however, it doesnt seem to work with DATE formats Ted - ask your real question the first time rather than asking a question about numbers. It'll get you to your answer faster and save people's time offering solutions to the problem that you don't actually have. If you store dates in ISO format (yyyy-mm-dd) you will be able to sort them easily. Quote Link to comment https://forums.phpfreaks.com/topic/37888-how-to-get-the-biggest-number/#findComment-181389 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.