SQL to select filename component of path

The 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
This entry was posted in Technical. Bookmark the permalink.