select t1.awb_no, t1.from_city as EI, t2.data_no as AC
from ehu_awb t1, plmdebtm t2
where t1.from_city <> t2.data_no
and t1.dep = 'EI'
and t1.cmp = 'BX'
and t1.awb_no = t2.AWB_NO就是查询T1中的from_city和T2中的data_no字段,如果相同的提单号awb_no,却为进口EI,则把T1的from_city UPDATE到T2的data_no,如何写update语法。
之前我写的不对。update plmdebtm
set plmdebtm.data_no =
(select ehu_awb.from_city
from ehu_awb
where ehu_awb.awb_no = plmdebtm.awb_no
and ehu_awb.from_city <> plmdebtm.data_no
and ehu_awb.dep = 'EI')上面的会把表plmdebtm的所有的行都更新了。
解决方案 »
- oracle em重建的一些问题
- 怎么看执行计划
- 求救````关于database link 的问题```
- 怎样在触发器中得到Index-by表中的记录??
- 如何在ORACLE客户端用ASP语句访问服务器端的数据呀?
- [Oracle][ODBC][Ora]ORA-12154: TNS: 无法处理服务名
- 100分求救!参与有分,不够可再加!!
- 急!急!急!关于微软提供的ORACLE的驱动问题。解决后立即给分。
- 寻找plsql developer完全文档:100分
- TK25W32.dll是什么东东?在哪里有下?
- 存储过程报错Warning: Procedure created with compilation errors
- 如何在.NET内操作oracle, 一次性执行多句sql
set plmdebtm.data_no =
(select ehu_awb.from_city
from ehu_awb
where ehu_awb.awb_no = plmdebtm.awb_no
and ehu_awb.from_city <> plmdebtm.data_no
and ehu_awb.dep = 'EI')
where exists
(select 1
from ehu_awb
where ehu_awb.awb_no = plmdebtm.awb_no
and ehu_awb.from_city <> plmdebtm.data_no
and ehu_awb.dep = 'EI');--10g可用merge
merge into plmdebtm
using ehu_awb on (ehu_awb.awb_no = plmdebtm.awb_no
and ehu_awb.from_city <> plmdebtm.data_no
and ehu_awb.dep = 'EI')
when matched then
update set plmdebtm.data_no=ehu_awb.from_city;
谢谢,上面的可以用,但是下面的那个语法不能用,出现错误的信息如下。ORA-38104:無法更新[ON 字句]中參照的資料欄:"PLMDEBTM"."DATA_NO"
因为你的update子句中参照了连接条件中的列
plmdebtm.data_no
ehu_awb.from_city