大赵传奇

援引事类,扬搉古今,举要删芜,言辩而理切--QQ276605216

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

有mysql路径字段,

E:\code-py-download\价\图片\2021005017\3\3-68590-8915ad8329a942f38fcb74306212a067-0.png

 

 

 如何取最后一个 \  前面部分?

SELECT LOCATE('\\',path_names_png),path_names_png FROM `yfyj`

select substring_index(path_names_png,'\\',-1) from yfyj
SELECT SUBSTRING_INDEX('and_this_may_go_like_this_too', '_', -1);
length对中文长度不好
SELECT path_names_png, LEFT(path_names_png, LENGTH(path_names_png) - LOCATE('\\', REVERSE(path_names_png))) from yfyj

char_length中文长度OK
SELECT path_names_png, LEFT(path_names_png, char_length(path_names_png) - LOCATE('\\', REVERSE(path_names_png))) from yfyj

 

posted on 2021-08-25 08:59  赵长青  阅读(179)  评论(0编辑  收藏  举报