List:General Discussion« Previous MessageNext Message »
From:Dotan Cohen Date:November 6 2006 12:53pm
Subject:Sorting MySQL queries
View as plain text  
I have a list of subjects, such as "Linux", "Open Source", and "the
World Wide Web". The subjects are stored in MySQL and being retrieved
via php. I currently organize them alphabetically with MySQL's "ORDER
BY ASC" argument, however, if there is a preceding "the " or "a " then
that is considered as part of the alphabetical order. Thus, all the
subjects starting with "the " are grouped together, as are the
subjects starting with "a ". How can I order by ascending, without
taking the preceding "the " or "a " into account?

** Example:
Now, the list is ordeded like this:
a Distribution
a Text Editor
a Virus
Bluetooth
Copyleft
DRM
Fedora
Firefox

However, I'd like it to be ordered like this:
Bluetooth
Copyleft
a Distribution
DRM
Fedora
Firefox
a Text Editor
a Virus

Current code:
$query  = "SELECT subject FROM table ORDER BY subject asc";
$result = mysql_query($query);


Thanks in advance.

Dotan Cohen

http://what-is-what.com/what_is/world_wide_web.html
Thread
Sorting MySQL queriesDotan Cohen6 Nov
  • Re: Sorting MySQL queriesChristian Hammers6 Nov
    • Re: Sorting MySQL queriesDotan Cohen6 Nov
      • Re: Sorting MySQL queriesChristian Hammers6 Nov