update a t01 set(t01.col1,...,字段列表) = (select t02.col1,...,字段列表 from a t02 where 条件)
where条件后面加上rownum = 1
更新700多行数据啊,rownum=1只更新了一行 唉
不是,where ... and rownum = 1写在括号里面。我经常这样更新数据表的。
给你一个差不多类似的例子,我原来写的更新语句: update dwledger t01 set per_balance = (select sum(s_dmbtr - h_dmbtr) AA from dwledger t02 where to_number(substr(t02.budat, 1, 6)) < to_number(substr(t01.budat, 1, 6)) and t01.hkont = t02.hkont and (t01.kunnr = t02.kunnr or t01.lifnr = t02.lifnr));
update dwledger t01
set per_balance = (select sum(s_dmbtr - h_dmbtr) AA
from dwledger t02
where to_number(substr(t02.budat, 1, 6)) <
to_number(substr(t01.budat, 1, 6))
and t01.hkont = t02.hkont
and (t01.kunnr = t02.kunnr or t01.lifnr = t02.lifnr));