Google sheets query join. The desired result can be obtained with a custom function.

Google sheets query join. Use Google Query to return results based on an Array.