Find Rows With Character Lengths Greater Than A Certain Amount In MySQL

Use the CHAR_LENGTH() function to find all rows that have a length greater than 60 characters in length.

SELECT * FROM sometable WHERE CHAR_LENGTH(somefield) > 60;

If you want to order your results by the length of the field as well then you can combine this with an ORDER BY clause.

SELECT * FROM sometable WHERE CHAR_LENGTH(somefield) > 60 ORDER BY CHAR_LENGTH(somefield) DESC;

This also works with MariaDB.

Add new comment

The content of this field is kept private and will not be shown publicly.