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中如何取得指定字串的長度?的詳細內容。更多資訊請關注PHP中文網其他相關文章!