AND NOT (f.filename ~ '^potato') AND f.location = l.id AND l.component = c.id
UNION SELECT l.path, f.filename, f.id as files_id, null as component
FROM files f, location l WHERE
AND NOT (f.filename ~ '^potato') AND f.location = l.id AND l.component = c.id
UNION SELECT l.path, f.filename, f.id as files_id, null as component
FROM files f, location l WHERE