max_w1 Posted May 30, 2011 Share Posted May 30, 2011 hi i am trying to use a query like this SELECT * FROM `fares` WHERE `KMS` >=201 LIMIT 0 , 30 which pops up a databse list of 30 rows which looks something like the one below KMS SL_AD SL_CH 205 122 120 210 124 120 215 125 120 220 127 121 225 128 122 all i want to do is somehow sort and get only the first row(205 122 120) in my php program/ Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/237875-selecting-the-top-row/ Share on other sites More sharing options...
wildteen88 Posted May 30, 2011 Share Posted May 30, 2011 all i want to do is somehow sort Sort by what? get only the first row If you're wanting to get the first record that is closet to KMS 201 Then just use LIMIT 1 rather than LIMIT 0, 30 $query = 'SELECT * FROM `fares`WHERE `KMS` >=201 LIMIT 1'; $result = mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/237875-selecting-the-top-row/#findComment-1222413 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.