在 MySQL 中,如何獲取特定字元的數字程式碼?
藉助 MySQL 字串函式 ASCII(),我們可以獲取特定字元的數字程式碼。它的語法為 ASCII(str),其中 ASCII() 函式的引數 str 是要檢索其第一個字元的 ASCII 值的字串。
它將返回作為引數提供的字串中最左邊的字元(即第一個字元)的數字程式碼。
示例
mysql> Select ASCII('T'); +------------+ | ASCII('T') | +------------+ | 84 | +------------+ 1 row in set (0.01 sec) mysql> Select ASCII('t'); +------------+ | ASCII('t') | +------------+ | 116 | +------------+ 1 row in set (0.00 sec) mysql> Select ASCII('Tutorialspoint'); +-------------------------+ | ASCII('Tutorialspoint') | +-------------------------+ | 84 | +-------------------------+ 1 row in set (0.00 sec) mysql> Select ASCII('tutorialspoint'); +-------------------------+ | ASCII('tutorialspoint') | +-------------------------+ | 116 | +-------------------------+ 1 row in set (0.00 sec)
廣告