Code:
SELECT 
 f.file, 
 i.last_access, 
 i.id AS pid 
FROM 
 files f, 
 images i 
WHERE 
  f.pid = i.id 
 AND 
  f.area = (SELECT MIN(area) FROM files WHERE pid = i.id)
But this returns all rows, not only the ones with minimum area value, if I add "GROUP BY pid" to the main query, only rows with bigger area values are returned (I currently have 2 different values for area). How could it be fixed?