There is a procedure GetFileList – returns, as the name implies, a list of files and a couple more options with them.
Is it possible then to use this procedure in the query select?
Something like this: select Field1 from Image where Field2 IN (call GetFileList ());
you should change it to a function
http://www.databasejournal.com/features/mysql/article.php/3569846/MySQL-Stored-Functions.htm