首页 > 代码库 > SUBSTRING(s,n,len)

SUBSTRING(s,n,len)

SUBSTRING(s,n,len) 用于获取指定位置的子字符串

mysql> SELECT SUBSTRING(breakfast,5) AS col1,  # 从第5个字符串开始获取    -> SUBSTRING(breakfast,5,3) AS col2,       # 从第5个字符串开始,获取3个    -> SUBSTRING(breakfast,-5) AS col3,        # (倒向)从第5个字符串开始获取    -> SUBSTRING(breakfast,-5,3) AS col4;      # (倒向)从第5个字符串开始获取,获取3个+-------+------+-------+------+| col1  | col2 | col3  | col4 |+-------+------+-------+------+| kfast | kfa  | kfast | kfa  |+-------+------+-------+------+

 

 

 

 

    

SUBSTRING(s,n,len)