开发者

Select rows from database by strlen

开发者 https://www.devze.com 2023-02-11 04:54 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号