Re: Natural order of things.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Crude, but effective.

ORDER BY length(title) DESC, title

You may also need to make it be:

ORDER BY substring(title, 1, 10), length(title) DESC, title

so you can get them alphabetical to start off with (the first 10
chars) then by the length to hack the "longer" ones with multiple
digits at the end, then by title to get it in order within decimal
positions.

On Wed, April 26, 2006 3:51 pm, tedd wrote:
> Hi gang:
>
> I posted the following question to the MySQL list, but the only
> answer I received thus far was a php solution (it didn't work for
> what I wanted).
>
> As such, maybe if I post a MySQL question to the PHP group, then I'll
> receive a MySQL answer -- so here goes:
>
> I'm using the following query, and it works.
>
> SELECT id, title, url_image_small
> FROM $dbtable
> WHERE type="type_title"
> ORDER BY title
> LIMIT $offset, $rowsPerPage"
>
> But, it sorts stuff like this:
>
> Basel Square 1
> Basel Square 10
> Basel Square 11
> Basel Square 2
> Basel Square 3
> Basel Square 4
> Basel Square 5
> Basel Square 6
> Basel Square 7
> Basel Square 8
> Basel Square 9
>
> What do I have to change to get it (the query) to sort like this:
>
> Basel Square 1
> Basel Square 2
> Basel Square 3
> Basel Square 4
> Basel Square 5
> Basel Square 6
> Basel Square 7
> Basel Square 8
> Basel Square 9
> Basel Square 10
> Basel Square 11
>
> Thanks in advance for any answers/suggestions
>
> tedd
> --
> --------------------------------------------------------------------------------
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux