Jump to content


Select order by substr of a field

  • Please log in to reply
1 reply to this topic

#1 yrrahxob

  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationKaty, Texas

Posted 23 November 2003 - 08:45 PM

I have the following query but it doesn\'t work. I get error code 1064.

SELECT * FROM `aud_desc` order by substr(aud_code,1,1)

Is it possible to do a select and order it by a substr of a column.

Please help

Thank you
Harry R. Box
[br]We must all hang together or we shall surely hang separately.
[br]A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."

#2 Kriek

  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationFlorida

Posted 23 November 2003 - 11:33 PM

In MySQL use the SUBSTRING() function.

SELECT * FROM aud_desc ORDER BY SUBSTRING(aud_code, 1, 1);

Jon Kriek ยท PHP Freaks
Sometimes the need to mess with their heads ...
... outweighs the millstone of humiliation.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users