Is there a way to select database table ro开发者_StackOverflowws 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?
SELECT * FROM table_name WHERE CHAR_LENGTH(column_name) < 5
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.
精彩评论