MySQL - How to select data by string length
SELECT * FROM table ORDER BY string_length(column);
Is there a MySQL function to do this (of course instead of
You are looking for
CHAR_LENGTH() to get the number of characters in a string.
For multi-byte charsets
LENGTH() will give you the number of bytes the string occupies, while
CHAR_LENGTH() will return the number of characters.
Read more... Read less...
The function that I use to find the length of the string is
length, used as follows:
SELECT * FROM table ORDER BY length(column);
I used this sentences to filter
SELECT table.field1, table.field2 FROM table WHERE length(field) > 10;
you can change 10 for other number that you want to filter.
select * from *tablename* where 1 having length(*fieldname*)=*fieldlength*
Example if you want to select from customer the entry's with a name shorter then 2 chars.
select * from customer where 1 **having length(name)<2**