How to select all data from specific tables for a given schema/prefix in MySQL Database
I think you actually want to use GROUP_CONCAT as per this StackOverflow answer.
This will allow you to prepare all rows into one statement that you can execute.