I'd go for a dynamic SQL statement.
Loop through the files, and build the query as you go..
in pseudo code:
$sQuery = "SELECT * FROM table WHERE 1=0 ";
// start loop
{
$sQuery .= " OR field=\"$filename\"";
};
What wil give you a query like
SELECT * FROM table WHERE 1=0 OR field="this" OR field="that";
In short, it will fetch all records where the filename matches any of the given files.
Now you can loop through the files again, and
for each file, loop through the resultset from the query to find a matching record.