Thank you for your answer. Actually I store the pictures in the DB
because they belong to the records fields. In this case it would be
meaningless to store the pictures on the filesystem, since there are
thousands of them and they are very small.
Just wondering if there is a way with only one query.