这是一个表结构(例如测试):
__________________________________________ | Field Name | Data Type | |________________|_________________________| | id | BIGINT (20) | |________________|_________________________| | title | varchar(25) | |________________|_________________________| | description | text | |________________|_________________________|
查询如下:
SELECT * FROM TEST ORDER BY description DESC;
但是我想按 字段大小/ 字段描述的 长度 排序。字段类型将为TEXT或BLOB。
SELECT * FROM TEST ORDER BY LENGTH(description) DESC;
该LENGTH函数以字节为单位给出字符串的长度。如果要计算(多字节)字符,请改用以下CHAR_LENGTH函数:
LENGTH
CHAR_LENGTH
SELECT * FROM TEST ORDER BY CHAR_LENGTH(description) DESC;