MySQL字符串函数:字符串截取
MySQL 字符串截取函数:left(), right(), substring(), substring_index()。还有 mid(), substr()。其中,mid(), substr() 等价于 substring() 函数,substring() 的功能非常强大和灵活。 1. 字符串截取:left(str, length) mysql> select left('sqlstudy.com', 3); +-------------------------+ | left('sqlstudy.com', 3) | +-------------------------+ | sql | +-------------------------+ 2. 字符串截取:right(str, length) mysql> select right('sqlstudy.com', 3); +--------------------------+ | right('sqlstudy.com', 3) | +--------------------------+ | com | +--------------------------+ 3. 字符串截取:substring(str, pos); substring(str, pos, len) 3.1 从字符串的第 4 个字符位置开始取