Let's say I have this table:
img_id, img_author, img_path
1 | BillyDoe | img1.jpg
2 | BillyDoe | img2.jpg
3 | BillyDoe | img3.jpg
I run another query that matches some specific criterias and that query returns an array many img_author names like: BillyDoe, JillDoe, JohnDoe etc...
The second thing I'll do is to get all the images from the image table that match the authors names
Would It be better to create a loop with all the author names the previous query returned and run the query multiple times like so
select img_path from images_table where img_author = $curr_author_name
Or I should create a custom function that will join all author names and run a single sql query with multiple 'or' operators like so:
select img_path from images_table where img_author = BillyDoe or img_author = JillDoe or img_author = JohnDoe ... x100 times
Will I have any kind of performance loss/gain doing either of these two ways? Or there are better alternatives like multi queries or so. Always talking performance wise, which method would be less resource intense?
Thank you.