table1 字段 a1,a2,a3,a4 主键 a1
table2 字段 a1,b2,b3,b4 主键 a1
现在想更新table1中满足table1.a1=table2.a1记录中字段a2的值 , table1.a2=table1.a2-table2.b2
我写的
update table1 a set table1.a2=table1.a2 - (select b.b2 from table2 b
where a.a1=b.a1 and a.a4='000001')
where a.a4='000001'
我感觉没问题 可是总执行不了 提示 ORA-00936: 缺少表达式
使用oracle8.0.5
table2 字段 a1,b2,b3,b4 主键 a1
现在想更新table1中满足table1.a1=table2.a1记录中字段a2的值 , table1.a2=table1.a2-table2.b2
我写的
update table1 a set table1.a2=table1.a2 - (select b.b2 from table2 b
where a.a1=b.a1 and a.a4='000001')
where a.a4='000001'
我感觉没问题 可是总执行不了 提示 ORA-00936: 缺少表达式
使用oracle8.0.5
where a.ColA = b.ColA
set table1.a2=table1.a2-table2.b2
from table2
where table1.a1=table2.a1
也谢谢 ncwuhh 关注,但我就是执行不了使用的是oracle8.0.5
不会和oracle版本有关系吧!呵呵!
from table2 b
where a.a1=b.a1 and a.a4='000001')
where a.a1=(select a1 from table2 c where a.a1=c.a1) and a.a4='000001';
set a.a2 = a.a2 - (select b.b2 from table2 b where b.a1 = a.a1)
where a.a4='000001'
和 我写的好象也差不多。但为什么?????谁能给我解释一下。难道和ORACLE有关系???
请各位实验一下再次谢谢大家的关注!!!!!!!!!!!!
>>where a.a1=b.a1 and a.a4='000001')
>>where a.a4='000001'改为: update table1 set a.a2=a.a2 -b.b2 from table1 a, table2 b
where a.a1=b.a1 and a.a4='000001'