kenw232 Posted December 20, 2015 Share Posted December 20, 2015 I need to sort the results of a select but there is no field to sort by in the table. So "order by" can't be used. This is because I have a couple fields (lattitude and longitude) that I have to use to calculate distance after the select, I cannot store the distance field in the same table ahead of time. mysql (root in 'CMS'): select * from Table; +-------------+ | account_num | lat | long ... +-------------+ | 16 | .. | 22 | ... +-------------+ Is it possible to take the results of the above, do my calculation (in PHP 5.5) against lat/long to get x, then somehow add this x (distance) to each row then resort based on it? mysql version: 5.1.46. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 20, 2015 Share Posted December 20, 2015 You can calculate the distance in the query and then ORDER BY distance Quote Link to comment 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.