从路径MYSQL提取文件名 [英] Extracting filenames from a path MYSQL

查看:666
本文介绍了从路径MYSQL提取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在一个简单的select语句使用字符串函数组合来从目录列表中提取文件名?

xxxx\xxxx\filename.txt

解决方案

此处.

Is there a simply select statement usign a combination of string functions to pull out a filename from a directory listing?

xxxx\xxxx\filename.txt

解决方案

The SUBSTRING_INDEX function is ideal for this:

SUBSTRING_INDEX(myFileName, '\\', -1)

The last argument of -1 says to return everything after the last \. Note that you have to escape the \ as \\.

There's a working SQL Fiddle here.

这篇关于从路径MYSQL提取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆