MySQL 中的 CHAR_LENGTH() 或 CHARACTER_LENGTH() 字符串函數用于檢索指定字符串的長度。該函數只會計算字符數,而忽略字符是單字節還是多字節。
示例
mysql> Select CHAR_LENGTH('New Delhi'); +--------------------------+ | CHAR_LENGTH('New Delhi') | +--------------------------+ | 9 | +--------------------------+ 1 row in set (0.00 sec) mysql> Select CHAR_LENGTH('NewDelhi'); +-------------------------+ | CHAR_LENGTH('NewDelhi') | +-------------------------+ | 8 | +-------------------------+ 1 row in set (0.00 sec) mysql> Select CHARACTER_LENGTH('NewDelhi'); +------------------------------+ | CHARACTER_LENGTH('NewDelhi') | +------------------------------+ | 8 | +------------------------------+ 1 row in set (0.00 sec) mysql> Select CHARACTER_LENGTH('New Delhi'); +-------------------------------+ | CHARACTER_LENGTH('New Delhi') | +-------------------------------+ | 9 | +-------------------------------+ 1 row in set (0.00 sec)
登錄后復制
以上就是MySQL中如何獲取指定字符串的長度?的詳細內容,更多請關注www.92cms.cn其它相關文章!