I'd like to loop through the results of a select subquery and use them yo fetch data off of another table:
SELECT alias, profile_picture
FROM public.profile
where user_id = (
SELECT friend_user_id
FROM public.friends
where user_id = 1059948007363671)::text
obviously this query returns:
ERROR: more than one row returned by a subquery used as an expression
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?