Re: [SQL ] MySQL 如何取字串長度

看板Database作者 (小惡魔)時間16年前 (2009/11/16 17:32), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《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

11/16 17:39, , 1F
太感謝啦....OK囉
11/16 17:39, 1F
文章代碼(AID): #1B0HmImU (Database)
文章代碼(AID): #1B0HmImU (Database)