SELECT * FROM table ORDER BY string_length(column);
Is there a MySQL function to do this (of course instead of string_length
)?
MySQL LENGTH() Function The LENGTH() function returns the length of a string (in bytes).
Well, you can use the LEN() function to find the length of a String value in SQL Server, for example, LEN(emp_name) will give you the length of values stored in the column emp_name.
What's the LEN() Equivalent in MySQL? In SQL Server, you can use the LEN() function to return the number of characters in a string. This is a Transact-SQL function that can also be used in Azure databases. In MySQL, you need to use the CHAR_LENGTH() function.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With