SQL to select filename component of path
2010-12-06The following works on MySQL to extract base filename component of a complete file path.
SELECT REVERSE(
SUBSTRING(
REVERSE(filepath),1,
LOCATE("/",REVERSE(filepath)
) - 1
)
) as basename
FROM Table