我想多表查询多个字段,其中某个字段在表中是多条信息,而其他的字段都是一条信息,我想把他们组合到一起成为一条记录。比如 查询table1,table2  (select t1.ID,t2.name from table1 t1,table2 t2 where t1.ID=t2.ID)现在ID只有一个,而table2中该ID对应两条记录,这两条记录name不相同
希望得到的查询的结果为:
ID    Name
123   张剑李玫
请问该如何实现?哪位好心人帮忙解答一下啊

解决方案 »

  1.   

    select t1.id,replace(wmsys.wm_concat(t2.name),',')
    from table1 t1,table2 t2 where t1.ID=t2.ID
    group by t1.id
      

  2.   


    select ID,
    substr(max(sys_connect_by_path(Name,'')),2) "Name",
    from (
    select t1.ID,t2.name ,row_number() over(order by t2.name ) rn
    from table1 t1,table2 t2 where t1.ID=t2.ID)
    start with rn=1
    connect by rn-1=prior rn
    group by IDOracle9I
    select t1.ID,wmsys.wm_concat(t2.name ) from table1 t1,table2 t2 where t1.ID=t2.ID
    group by t1.ID; 
    10G好像是这样写的
      

  3.   

    谢谢各位的热心帮助!
    谢谢hyee,yangfuen637200 用你们的方法解决问题