to answer your specific question, to strip off the last four characters, you could try a combination of nested functions involving LEFT and LENGTH - 4
but mysql has an even neater function
to remove the "extension" portion of a file name, and assuming that the file name contains only one "dot" (period), the following will work nicely whether the extension is 3 characters or four (e.g. oldnickj.
jpeg versus oldnickj.
jpg)
SELECT SUBSTRING_INDEX(filename,'.',1) AS image ...
