Reputation: 12512
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?
Upvotes: 37
Views: 41881
Reputation: 55673
LENGTH("my_string")
Return the length of a string in bytes
SELECT * FROM table_name WHERE LENGTH(column_name) < 5
Keep in mind that characters can be made up of multiple bytes like those in UTF-8.
Upvotes: 9