Jump to content


Photo

Arranging mysql result by result length


  • Please log in to reply
2 replies to this topic

#1 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 13 October 2006 - 04:35 PM

How do i order my mysql results by the longest length eg


I have the following words in the db

string
stringest
stringer

how do i get the following results

stringest
stringer
string

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 October 2006 - 07:28 PM

ORDER BY LENGTH(yourField) DESC
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 13 October 2006 - 08:42 PM

thanks u guys rock.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users