mysql - 如何在sql语句中判断一个字段(内容为文件的路径)里面的文件后缀名?求大神告知,不会啊
PHPz
PHPz 2017-04-17 13:35:37
0
2
610
PHPz
PHPz

学习是最好的投资!

reply all(2)
巴扎黑

MYSQL:

SELECT RIGHT(RTRIM(@Path), LOCATE('.',REVERSE(RTRIM(@Path))) - 1)

SQLSERVER:

SELECT RIGHT(RTRIM(@Path), CHARINDEX('.',REVERSE(RTRIM(@Path))) - 1)

Assume the @Path placeholder is your field. Idea: To find the last character ., reverse it and find the position of the first ., and then go to the original string to intercept the characters after ..

刘奇

I don’t have MySQL at hand, but you can do this in Oracle:

select substr(PATH, instr(PATH, '.') + 1) from 表名

As for MySQL, you can just check if there are corresponding functions.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!