如:select xm from yhb where bm='车间',得到:
张三
李四
王五
赵六
有另一表:人员表(人数,姓名集...)
如何将"张三,李四,王五,赵六"插入到人员表的姓名集字段中?谢谢!!

解决方案 »

  1.   

    你是update还是insert?
    是insert的话,在插入“张三,李四,王五,赵六”后,人员表的其他字段如何操作?
    你最好能把两个表结构和数据都贴些出来。
      

  2.   

    当然用insert了,假设只查询到4条记录,如何把这4条记录合成一个字符串?
      

  3.   

    yhb:
    工号 姓名 部门
    01 张三 车间
    02 李四 车间
    03 王五 车间
    04 赵六 车间人员表:
    人数 到班人员 日期 
    3 张三,李四,王五,赵六 2009-12-6
    我如何才能得到第二个表的结果?
      

  4.   

    select wmsys.wm_concat(xm) 
    from yhb where bm='车间';oracle 啥版本?
      

  5.   

    那麻烦些,不能用我上面的函数了。
    你只有用SYS_CONNECT_BY_PATH把“张三,李四,王五,赵六”拼在一列。
    具体用法你网上搜搜。
      

  6.   

    wmsys.wm_concat(把多行转换成一合并列)
    在9i 中好象没有这个函数呀?
      

  7.   

    举个例子吧
    你试着照猫画虎一下 呵呵 
    SQL> select * from t1;        ID NAME
    ---------- ----------
             1 wh
             1 wp
             1 wj
             2 ha
    SQL> select ltrim(sys_connect_by_path(name,','),',') names
      2  from
      3  (
      4  select id,name,
      5  row_number() over(partition by id order by id) rn,
      6  count(*) over (partition by id) cnt
      7  from t1
      8  )
      9  where id=1 and level=cnt
     10  start with rn=1
     11  connect by prior rn=rn-1 and prior id=id;NAMES
    --------------------
    wh,wp,wj
      

  8.   

    SQL> select name
      2  from t1
      3  where id=1;NAME
    ----------
    wh
    wp
    wj
      

  9.   

    用sys_connect_by_path速度太慢了,让人难以忍受!
    我这个表中大概有1万多条记录呀.