SUBSTRING

SUBSTRING(s, start, length)    从字符串 s 的 start 位置截取长度为 length 的子字符串

从字符串 Hello World 中的第 2 个位置截取 3个 字符:

eg:select SUBSTRING("Hello World",2,3) as test;

MySQL 截取字符串

 

 

 注:字符串的索引是从1开始的。

如果第三个参数不传,是从start位置截取到最后

eg:select SUBSTRING("Hello World",2) as test;

MySQL 截取字符串

 

 SUBSTRING(str FROM pos FOR len) 与上面结果一样,从字符串str的pos位置截取长度为len的子字符串

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2021-06-12
  • 2021-12-04
  • 2021-08-19
  • 2021-07-19
  • 2021-09-20
  • 2022-12-23
相关资源
相似解决方案