早上,可以根据字符长度进行对准sql排序数据吗? - Y4 `, F9 P) k0 M* {6 d例如 SELECT * FROM database ORDER BY data.length() % S( [/ Z r0 m1 t4 l- T ' w- j/ S* [3 }% A+ A解决方案: ' U# C e4 ]9 W$ i# o( @ 我想你想用这个功能:http : //dev.mysql.com/doc/refman/5.0/zh-( q+ b7 @# a. z- B% T: l _) B x
CN/string-functions.html#function_char- # h& H ^, W1 w6 d& D U/ tlength * l9 M, P' S4 g; ]7 O aSELECT * FROM table ORDER BY CHAR_LENGTH(field)你只能简单地使用它LENGTH(),但要小心,因为它计算字节数(对于多字节字符串,这不会给你预期的结果)。