SUBSTRING_INDEX的用法: •SUBSTRING_INDEX(str,delim,count) 在定界符 delim 以及count 出现前,从字符串str返回自字符串。若count为正值,则返回最终定界符(从左边开始)   

若为-1则是从后往前截取

SELECT substring_index('Hn_P00001', 'P', -1)  -- 结果是00001

 

concat('1','2','3')可以拼接3个值

-1是从右往左遇到第一个/(不包含第一个/),返回20171205171645.jpg

5是从左往右遇到第五个/(不包含第五个/) ,返回http://192.168.2.227:8080/huikeportal/inspectionsImg

SELECT SUBSTRING_INDEX('http://192.168.2.227:8080/huikeportal/inspectionsImg/20171205171645.jpg','/',5)


-- 返回值http://192.168.2.227:8080/huikeportal/inspectionsImg/thumbnail20171205171645.jpg
SELECT concat(SUBSTRING_INDEX('http://192.168.2.227:8080/huikeportal/inspectionsImg/20171205171645.jpg','/',5),
'/thumbnail',SUBSTRING_INDEX('http://192.168.2.227:8080/huikeportal/inspectionsImg/20171205171645.jpg','/',-1))

mysql函数之SUBSTRING_INDEX(str,"/",-1)

---------------------
作者:唯不见相思
来源:CSDN
原文:https://blog.csdn.net/qq_29883183/article/details/78723840
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-04-12
相关资源
相似解决方案