select id from table_name order by abs(id);

Dave


Dundee!


On Tue, Feb 12, 2002 at 09:46:25AM +1000, David Mackay wrote:
> G'Day folks, 
> 
> 
> New to PHP/MySQL. 
> 
> Want to order the results of a SELECT by their 'absolute' value, not their
> sign.
> So regardless of whether it's +37 or -37, they are both 37 and thus both
> come between 38 & 36, regardless of whether they're + or -.
> eg.
> 100
> -99
> -92
> 91
> 72
> -38
> 37
> -37
> etc... 
> 
> I have the order DESC but it puts 100 first, and -100 last,
> (that's what you'd usually want, but
> I need the extremes grouped at one end,
> down to the middle point zero......). 
> 
> In my fantasy world I could do a  ORDER BY ABS(number) DESC
> If there was any other way to achieve the same result that would be just
> dandy... 
> 
> I bet this is obvious.
> 
> 
> Thanks for your time,
> 
> David Mackay
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to