How to get around the "query in a loop" problem? And is this a problem?

   

v20240901