MySQL Order Table By Character Length
Thu, 09/24/2009 - 08:45 | by philipnorton42
As part of debugging a bit of code I needed to know the longest possible field lengths that a record contains. You might need to know this if you are performing a database migration. The following query returns a field, along with the length of the string, and orders the results by the number of characters in that string.
SELECT field, CHARACTER_LENGTH(field) as fieldCharacterCount FROM table ORDER BY fieldCharacterCount DESC
Comments
Post new comment