Forum .LRN Q&A: Re: How can I find out what community_id an acs_object belongs to?

Cathy,

No need to traverse, you can do something like

select o2.object_id,
       o2.object_type, 
       x.object_id as object_id_two, 
       x.object_type as object_type_two
from acs_objects o2,
     (select o.object_id,
      tree_ancestor_keys(o.tree_sortkey) as ancestor_key,
      o.object_type 
      from acs_objects o 
      where o.object_id = :object_id) x 
where o2.tree_sortkey = x.ancestor_key 
      and o2.object_id in (select community_id 
                           from dotlrn_communities_all)

Of course you can stil tweak that to optimize stuff but the idea is there.