我想把前面1-30条记录aaa列的数据更新到后面31-40条记录去,我想用下面的语句可是不行
updata access set aaa=(select aaa from access where name='01') where name='03'说明:1-30条记录name列都等于'01',31-40条记录name列都等于'03'

解决方案 »

  1.   

    Have no an answer,oneself UP,UP,UP,我都帮了别人回答,自己的没有人帮,惨
      

  2.   

    因为你括号内的SELECT语句得出来的是一个数据集,所以报错。
    updata access set aaa=(select distinct aaa from access where name='01') where name='03'
      

  3.   

    这个基本上难~一条条更新吧!方法笨了点点~
    rst1= execute select aaa from access where name='01'
    rst2= execute select aaa from access where name='03'
    do while not rst2.eof
    (
    rst2.aaa=rst1.aaa
    rst1.movenext
    rst2.movenext
    )
    呵呵
      

  4.   

    to ntsnow(玛娅传说) 
    这个"select distinct aaa from access where name='01'"也是返回一个数据集,还是不行
      

  5.   

    记录条数都不一样多,怎么个更新啊?
    如果肯定记录条数是一样的话,那么搞两个query,象ljlfromjj(学习ing)所说的方法还是可以的
    ...
    qeury1.open;
    ...
    query2.open;
    while (not query1.eof) and (not query2.eof) do
    begin
      Query2.edit;
      Query2.fieldbyname('aaa').asType := query1.filedbyname('aaa').asType;
      Qeury2.post;
      Qeury1.next;
      Query2.next;
    end;
      

  6.   

    对不起,记录条数一样多的,是我上面找错了!
    更正上面的:
    说明:1-30条记录name列都等于'01',31-60条记录name列都等于'03'
      

  7.   

    这种情况跟我遇到的一样,我们每月的报表都差不多,
    完全可以在SQLSERVER下实现,SQL语句不记得了,要在单位上翻代码
    有个FROM SELECT 语句,ACCESS不支持,但SQLSERVER,
    明天找出来给你
      

  8.   

    jingbianfc(『静⊙变』) 阁下,I first thanks for you,I will Wait for a while you Answer
      

  9.   

    做了个试验,Table1有6个记录,字段N1的值分别从1到6
    下面的结果让后面的3条记录的N1字段值变为2、4、6,可以借鉴一下
      query1.Close;
      query1.SQL.Clear;
      query1.SQL.Add('select * from Table1 where N1 <= 3');
      query1.Open;
      query1.First;
      query2.Close;
      query2.SQL.Clear;
      query2.SQL.Add('select * from Table1 where N1 > 3');
      query2.Open;
      query2.First;
      while (not query1.Eof) and (not query2.Eof) do
      begin
        Query2.Edit;
        Query2.FieldByName('N1').Value := Query1.FieldByName('N1').asfloat * 2;
        Query2.Post;
        Query1.Next;
        Query2.Next
      end;
      Query2.ApplyUpdates;
    这种方法不行的话还可以用临时表,将要更新的记录move出去,修改完成后再move回来,呵呵
      

  10.   

    To chinajavis(我选择 我喜欢):
         你这种办法可以可是太笨了点呀  (:,又是一个"While",不太灵活 (:,Did not simle to you
      

  11.   

    updata access set aaa=(select aaa from access where name='01') where name='03'
    这个语句你叫数据库怎么更新,除去Name字段你总得还有关键字短把假设为RowNoupdata access 
    set aaa=a.No
    (select (No-30) as No ,name,aaa
    where No>'30') a,access b
    where No<=30 and a.No=b.No最然我管道晕乎乎的是
    1-30是30条记录,31-40是10条记录
    麻烦你告诉我,
    你到底想干什么
      

  12.   

    如果没有什么更好的办法能一次性搞定的话我觉得还是可以这么做的。
    我等待高手的解答,感谢你不laugh at me
      

  13.   

    非常感谢楼上各位的回答,我的表是这样的:
    字段:
    ID   oper_no    prompt       run1 run2 run3 run4  (run1代表:删除,run2代表:新增,..)
    数据如下:
    1    01         系统操作      1    0     1    0
    2    01         账备操作      0    1     1    0
    .    ..         .....         ........
    30   01         报表管理      1    1     1    131   02         系统操作      1    0     0    0
    32   02         账备操作      0    0     0    0
    .    ..         .....        1     1     1    1
    60   02         报表管理      0    0     0    061   03         系统操作      1    0     1    0
    ........
    90   03         报表管理      1   .....
    ...
    ...
    ...........
    就这么多吧应看得明白了.
    我是想把"01"操作员的权限原来的复制给"03",
    操作员很多我想随意把某某操作员权限复制
      

  14.   

    sorry,上面又打错了一个字,把"原来"改为"原本"
      

  15.   

    这是oracle 下PL/SQL 的写法 ,自己看着该吧declare   ' 使用游标
       v_run1 integer;  // 定义变量
       v_run2 integer;
       .......          //继续定义
       cursor c_right is select run1,run2 .....  from 表 where oper_no ='01';
    begin
        open c_right ;
        loop 
          fetch c_right into v_run1 ,v_run2  ......  ;
          update  表 set run1= v_run1 ,run2=v_run2 .....  where oper_no='03';
          exit when c_right%notfound ;
          end loop ;
          Close c_right ;
    end;