Forum OpenACS Q&A: Response to Outer join Query for Users_files: Help

Collapse
Posted by Dan Wickstrom on
Grrr... I should quit while I'm ahead, the above query needs a group by to work with multiple entries in users_files:

select u.user_id,
       u.last_name,
       uf.file_owner_flag
from users u 
       LEFT OUTER JOIN 
     (select owner_id, '*'::text as file_owner_flag 
        from users_files u
       where file_size > 0 
         and owner_id = u.owner_id
    group by owner_id, file_owner_flag) uf ON u.user_id = uf.owner_id;