Pierre, I thought the best solution could be the following (inspiration is this point ):
a = A.arel_table b = B.arel_table subquery = b.project(b[:a_id].as('A_id')).where{c > 4} subquery = subquery.as('intm_table') query = A.join(subquery).on(subquery[:A_id].eq(a[:id]))
There is no particular reason for naming an alias as "intm_table", I just thought it would be less confusing.
Ashwin saval
source share