title: Postgres RETURNING clause with join
body: <p>In the following SQL, how could I make the <code>RETURNING</code> clause join to something else and return the joined row(s)? Here it only returns the row from <code>mytable</code> that was updated, but I'd like it to return that row joined to something in another table.</p>
  
  <pre><code>UPDATE mytable
  SET    status = 'A' 
  FROM  (
     SELECT myid
     FROM   mytable
     WHERE  status = 'B'
     ORDER BY mycolumn
     LIMIT  100
     FOR   UPDATE
     ) sub
  WHERE  mytable.myid = sub.myid
  RETURNING *;
  </code></pre>
  
  <p>I could do another query from my client application, but I'd like to know if there's a way to do it from within Postgres within having to make a separate roundtrip to the DB.</p>