On 2006-11-06 Dotan Cohen wrote: > 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?
Make a second column that only contains ALTER TABLE table ADD cooked_subject; UPDATE table SET cooked_subject = ereg_replace('^(a|the) ', '', subject); (I don't know how the regular expression function was called exactly but you get the idea) SELECT subject FROM table ORDER BY cooked_subject; Of course you could also put the regular expression in the SELECT but that would be slower. bye, -christian- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]