LTRIM(
select max(sys_connect_by_path(prod_id,',')) from
(
select
p.prod_id,rownum ro
from
t_prod p,t_com c
where
p.relation_id = c.recid
) newtab
start with newtab.ro = 1
connect by prior newtab.ro = newtab.ro - 1),',')
该例为从产品表中取出relation_id等于公司表中的rec_id 的产品的产品ID,多个产品ID最终以“面包,牛奶”的形式得到。