How can I add a column from a different table to my recursive SQL query?
<p>My SQL is very rusty but I need to modify a query to collect some new information. timer_call_data tcd as used in the query below also has an id field so timer_call_data.id is what I need to select. I suspect the actual solution is trivial but I'm not at all clear on where/how I can add timer_call_data to the query and join it in a way that would make it available in the final select. Any assistance would be greatly appreciated.</p>

<pre><code>with recursive cp (id, parent, timer, name) as ( 
SELECT tc.id, tc.parent, tc.timer, timer.name 
FROM  timer_callpath tc inner join timer on tc.timer = timer.id 
where timer.trial = 2 and tc.parent is null 
UNION ALL 
SELECT d.id, d.parent, d.timer, cp.name || ' =&gt; ' || dt.name 
FROM timer_callpath AS d JOIN cp ON (d.parent = cp.id) 
join timer dt on d.timer = dt.id where dt.trial = 2 )
select cp.id from cp
left outer join timer_call_data tcd on tcd.timer_callpath = cp.id
left outer join thread h on tcd.thread = h.id
where cp.name = '.TAU application' and h.thread_index = '0' 
</code></pre>