是否可以按字符总数对 sql 数据行进行排序?
例如 SELECT * FROM database ORDER BY data.length()
SELECT * FROM database ORDER BY data.length()
SELECT * FROM table ORDER BY length(data) desc
Where data is varchar field
I think you want to use this: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length
SELECT * FROM table ORDER BY CHAR_LENGTH(field)
You can use just simply LENGTH(), but beware, because it counts the byte number (which won't give you the expected result with multibyte strings).
SELECT * FROM database ORDER BY Len(data)
SELECT * FROM YourTable ORDER BY LENGTH(Column_Name) DESC
e.g;
SELECT * FROM Customer ORDER BY LENGTH(CustomerName) DESC
For anyone doing with Sqlite
SELECT * FROM table ORDER BY LENGTH(field) DESC