SUBSTRING(s,n,len)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)的主要内容,如果未能解决你的问题,请参考以下文章

bzoj2555 SubString

leetcode python 030 Substring with Concatenation of All Words

005. Longest Palindromic Substring

Longest Substring Without Repeating Characters

LC1044. Longest Duplicate Substring最长重复子串:二分答案 + 滚动哈希

代码片段 - Golang 实现集合操作