title: Postgresql how to combine these two queries?
body: <p>I'm trying to combine these two queries, but I can't figure out how</p>
  
  <pre><code>SELECT id FROM comments WHERE thread_id = $1 AND parent_id is NULL
  </code></pre>
  
  <p>This returns a integer. i.e - 5</p>
  
  <p>And then use the id result (5) for this recursive query</p>
  
  <pre><code>With RECURSIVE recursetree AS
  (
   SELECT * FROM comments WHERE comment_id = (use the id 5 here)
   UNION
   SELECT t.*
   From comments t
   JOIN recursetree rt ON rt.comment_id = t.parent_id                         
   )
   SELECT * from recursetree
  </code></pre>