Can I join, using another query?

Let’s say I have a query like this:

query = from(chat in Chat, where: xxx)

And another query like this:

comments = from(
    chat in query, 
    join: comment in Comment, 
    on: comment.chat_id == chat.id, 
    select: comment
)

This works, but if I ever wanted to use the comments query in another query, i’d get this error: (Ecto.Query.CompileError) only one select expression is allowed in query

Is there any way to rewrite the comments query, without using :select? Meaning the query starts like from(comment in Comment, ...)?

Check out select_merge/3

select_merge won’t work for me here. 1. You can’t select_merge two structs together, and 2. I don’t want a merged response, I just want the plain struct.

from comment in Comment, join: c in subquery(query), …