码迷,mamicode.com
首页 > 其他好文 > 详细

SUBSTRING(s,n,len)

时间:2017-05-23 20:30:08      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:code   指定   fast   位置   bsp   substring   string   sql   substr   

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)

标签:code   指定   fast   位置   bsp   substring   string   sql   substr   

原文地址:http://www.cnblogs.com/pzk7788/p/6895772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!