MySQL 字串截取

來源:互聯網
上載者:User

MySQL 字串截取

MySQL 字串截取

1、從左開始截取字串
left(str, length)
說明:left(被截取欄位,截取長度)
例:select left(content,200) as abstract from my_content_t

2、從右開始截取字串
right(str, length)
說明:right(被截取欄位,截取長度)
例:select right(content,200) as abstract from my_content_t

3、截取字串
substring(str, pos)
substring(str, pos, length)
說明:substring(被截取欄位,從第幾位開始截取)
substring(被截取欄位,從第幾位開始截取,截取長度)
例:select substring(content,5) as abstract from my_content_t
select substring(content,5,200) as abstract from my_content_t
(註:如果位元是負數 如-5 則是從後倒數位元,到字串結束或截取的長度)

4、按關鍵字截取字串
substring_index(str,delim,count)
說明:substring_index(被截取欄位,關鍵字,關鍵字出現的次數)

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.