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 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. 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 ..) 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 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
Archived
This topic is now archived and is closed to further replies.