推 tabear:太感謝啦....OK囉 11/16 17:39
※ 引述《tabear (胖熊)》之銘言:
: 我是用 MySQL
: 假設我現在有的欄位A
: 我想透過欄位A內容的長度去做排序 SQL語法可以做到嗎?
: 我原本的想法 select * from table order by A desc
: 結果只是照字母排序 = =
: 請問有辦法用 欄位的內容長度去排序嗎(越長的排越前面)??
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_length
select LENGTH(A) as length_count from table order by length_count desc
你試試看
--
PHP MVC CodeIgniter 繁體中文手冊: http://tinyurl.com/mduyv8
PHP MVC CodeIgniter 繁體中文討論區:http://tinyurl.com/yayzoz8
PHP MVC CodeIgniter 中文官方網站: http://tinyurl.com/yatds8n
Appleboy Blog 電腦技術: http://blog.Wu-Boy.com
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.107.202