腊月的季节

破万卷总结六

MySQL字符串操作

字符串截取函数:left(),right(),substring(),substring_index(),mid(),substr()

  • left(str,length)

    1
    2
    3
    4
    5
    6
    > select left('example.com',3);
    +----------------------+
    |left('example.com',3) |
    +----------------------+
    |exa |
    +----------------------+
  • right(str,length)

    1
    2
    3
    4
    5
    6
    > select right('example.com',3);
    +----------------------+
    |right('example.com',3)|
    +----------------------+
    |com |
    +----------------------+
  • substring(str,4)从第四个字符位置开始取,直到结束

    1
    > select substring

热评文章