Select rows from database by strlen

santa picture santa · Feb 19, 2011 · Viewed 37.5k times · Source

Is there a way to select database table rows where a given value is a certain length, for example, less than 5 chars long?

In PHP that would be strlen.

Is there anything similar in MySQL?

Answer

Derek Prior picture Derek Prior · Feb 19, 2011
SELECT * FROM table_name WHERE CHAR_LENGTH(column_name) < 5