SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id ...
A recursive query starts with either one non-recursive sub-query or several non-recursive sub-queries joined by UNION or UNION ALL, and ends with exactly one recursive sub-query joined by UNION ALL. A ...