Jump to content

Can I sort results manually after a fetch?


Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.