Reputation: 24768
I have the most simple SQL
SELECT * FROM words
It has 13000 words (varchar). I need to get the longest word first in my output. I guess it might be possible with the WHERE command?
Alternative
If it doesn't work like that, is there a smart way to sort my output array so it will order it by the longest word first (in the 'word'-column). It looks like this (in the output loop)?
$output_array[$row['word']] = $row['another_word'];
Upvotes: 3
Views: 2261
Reputation: 655309
Ordering the words by its length should do it:
SELECT *
FROM words
ORDER BY LENGTH(word) DESC
Upvotes: 7