[aklug] Re: MySQL sorting alphanumerics

From: Tim Gibney <timgibney76@gmail.com>
Date: Sat Apr 03 2010 - 13:54:09 AKDT

At the risk of being flamed here have you considered a different database
that has support for posix regex like PostgreSQL?
http://www.postgresql.org/docs/8.1/static/functions-matching.html

There is someone who had the same problem as yourself but had instructions
on how to solve it with PostgreSQL instead mentioned here

http://archives.postgresql.org/pgsql-novice/2002-08/thrd2.php#00004

On Sat, Apr 3, 2010 at 10:30 AM, Shane Spencer <shane@bogomip.com> wrote:

> I keep forgetting that there is a specific way to do things and a
> generic way to do things. Generic would be using a natural sort which
> takes a lot into account. Specific would be knowing your limits and
> working directly within them. So I thunk to myself - Shane - what is
> the super specific way to do this assuming there are only 1-99 ports
> in a switch and Null-A-Z modules.
>
> The subselect is for show.. stating it can deal with random sorting.
> I'm not sure if using three substrings is less evil than the natural
> sort function. But it's specific :)
>
> mysql> select a from (select a from xyz order by RAND()) as abc order
> by substring(a,1,1), substring(a,3,1), substring(a,2,1);
> +------+
> | a |
> +------+
> | 1 |
> | 10 |
> | 2 |
> | 3 |
> | 4 |
> | 42 |
> | 9 |
> | A3 |
> | A9 |
> | A10 |
> | C7 |
> | D3 |
> +------+
> 12 rows in set (0.00 sec)
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Apr 3 13:54:19 2010

This archive was generated by hypermail 2.1.8 : Sat Apr 03 2010 - 13:54:19 AKDT