syntax101 Posted December 8, 2007 Share Posted December 8, 2007 help how do you get the hightst number in the database ex. order_num 1 4 10 2 3 4 6 7 RESULT 10 Quote Link to comment https://forums.phpfreaks.com/topic/80734-solved-selecting-the-highest-number-in-the-database/ Share on other sites More sharing options...
syntax101 Posted December 8, 2007 Author Share Posted December 8, 2007 i tried to use $sql = 'SELECT max(order_num) from orders '; - no result but it wont work in php then i tried it in phpyadmin select max(order_num) from `orders` - result ok it works can anybody help me. Quote Link to comment https://forums.phpfreaks.com/topic/80734-solved-selecting-the-highest-number-in-the-database/#findComment-409625 Share on other sites More sharing options...
syntax101 Posted December 8, 2007 Author Share Posted December 8, 2007 i already got it $sql = 'SELECT order_num from orders where order_num = (Select max(order_num) from orders)'; thanx to the moderator who taught me how to use select in a select data from table where data = (select ..) Quote Link to comment https://forums.phpfreaks.com/topic/80734-solved-selecting-the-highest-number-in-the-database/#findComment-409631 Share on other sites More sharing options...
fenway Posted December 9, 2007 Share Posted December 9, 2007 Actually, you don't need a subselect, it's just a single table: SELECT max(order_num) from orders Quote Link to comment https://forums.phpfreaks.com/topic/80734-solved-selecting-the-highest-number-in-the-database/#findComment-410370 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.