title: PostgreSQL loop through subquery
body: <p>I'd like to loop through the results of a select subquery and use them yo fetch data off of another table:</p>
  <pre><code>SELECT alias, profile_picture 
  FROM public.profile 
  where user_id = (
      SELECT friend_user_id 
      FROM public.friends 
      where user_id = 1059948007363671)::text
  </code></pre>
  <p>obviously this query returns:</p>
  <pre><code>ERROR:  more than one row returned by a subquery used as an expression
  </code></pre>
  <p>What would be the best way to loop through the subquery results and assign it to a temporary variable that pubic.profile could use to fetch the respective profile info?</p>