MYSQL根据字符串长度排序可以使用length函数计算出字符串长度然后进行排序 具体写法:SELECT * FROM `ymwl_relatedlink` order by LENGTH(TRIM(`name`)) desc
//代码中的应用案列 $sql = "SELECT * FROM `ymwl_relatedlink` order by LENGTH(TRIM(`name`)) desc"; db::query($sql); $result = db::fetch_all(); foreach ($result as $val) { $arr_tmp[] = $val; } util::put_file(PATH_DATA . "/file_cache/relatedlink_table_cache.php", '<?php $relatedlink_data = ' . var_export($arr_tmp, true) . ';');
如果本文对你有帮助,欢迎打赏本站