MySQL - character order

I have the easiest SQL

SELECT * FROM words

He has 13000 words (varchar). I need to get the longest word in my output. I think this is possible with the WHERE command?

Alternative

If this does not work, is there a way to sort my output array, so it will order it with the longest word first (in the "column word"). Does it look like this (in the output loop)?

$output_array[$row['word']] = $row['another_word'];
+3
source share
2 answers

Ordering words along its length should do this:

SELECT *
FROM words
ORDER BY LENGTH(word) DESC
+6
source
select * from words order by len(my_field) desc;
0
source

Source: https://habr.com/ru/post/1734589/


All Articles