我想把前面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'
updata access set aaa=(select aaa from access where name='01') where name='03'说明:1-30条记录name列都等于'01',31-40条记录name列都等于'03'
updata access set aaa=(select distinct aaa from access where name='01') where name='03'
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
)
呵呵
这个"select distinct aaa from access where name='01'"也是返回一个数据集,还是不行
如果肯定记录条数是一样的话,那么搞两个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;
更正上面的:
说明:1-30条记录name列都等于'01',31-60条记录name列都等于'03'
完全可以在SQLSERVER下实现,SQL语句不记得了,要在单位上翻代码
有个FROM SELECT 语句,ACCESS不支持,但SQLSERVER,
明天找出来给你
下面的结果让后面的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回来,呵呵
你这种办法可以可是太笨了点呀 (:,又是一个"While",不太灵活 (:,Did not simle to you
这个语句你叫数据库怎么更新,除去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条记录
麻烦你告诉我,
你到底想干什么
我等待高手的解答,感谢你不laugh at me
字段:
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",
操作员很多我想随意把某某操作员权限复制
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;