比如表A
task_id     opeti
1                
1                
1                
2                ceshi_a表B
task_id     opeti
1                xiugaiceshi
1                xiugaiceshi 1
1                xiugaiceshi 2
2                ceshiceshi
需要把表A中task_id = 1的opeti值设置成表B中task_id值=1的opeti的值,这个要怎么实现呢?小白一枚,望大神们不吝赐教,谢谢。

解决方案 »

  1.   

    比如表A
    task_id         cgi                  opeti
    1                 010-010
    1                 010-020
    1                 010-010
    2                 011-111             ceshi_a表B
    task_id     cgi                      opeti
    1                010-010           xiugaiceshi
    1                010-012           xiugaiceshi 1
    1                010-010           xiugaiceshi 2
    2                022-011           ceshiceshi
    刚才举得例子可能不太严谨,应该是三个字段,需要是表A的task_id=1的与表A中cgi=表B中cgi对应的更新opeti的值。表A与表B是通过cgi关联的,然后task_id =1 将表B中opeti的值添到表A中对应task_id与cgi的opeti中,谢谢版主大人。
      

  2.   

    -- 看看这个能不能达到你的要求
    update a 
    set op = (select op from b where a.id = b.id and a.cgi = b.cgi)
    where exists(select * from b where a.id = b.id and a.cgi = b.cgi)
      

  3.   

    提示的是“ora-01427:单行子查询返回多个行”
      

  4.   

    opeti 列的编号有什么规则?
      

  5.   

    opeti列内容是没规则的
      

  6.   

    task_id     cgi                      opeti
    1                010-010           xiugaiceshi
    1                010-012           xiugaiceshi 1
    1                010-010           xiugaiceshi 2
    这个情况, id 相同,cgi 也相同,取哪个 op 呢?
      

  7.   

    比如表A
    task_id         cgi                  opeti
    1                 010-010
    1                 010-021
    1                 010-011
    2                 011-111             ceshi_a表B
    task_id     cgi                      opeti
    1                010-010           xiugaiceshi
    1                010-021           xiugaiceshi 1
    1                010-011           xiugaiceshi 2
    2                022-011           ceshiceshi确认了一下,同一task_id下,cgi是不会重复的,也就是同一张表下cig是唯一的,这样怎么实现呢?多写版主大人了@wmxcn2000
      

  8.   

    也就是比如我想把task_id=1的全部B表中opeti字段值赋给A表对应的task_id和cgi的opeti字段。