Input Array does not match ?: SELECT sf.*, g.*
FROM submission_galleys g
LEFT JOIN submission_files sf ON (g.file_id = sf.file_id)
LEFT JOIN submission_files nsf ON (nsf.file_id = g.file_id AND nsf.revision > sf.revision)
WHERE g.galley_id = 0
AND nsf.file_id IS NULL AND g.submission_id =