update CUSTOMER_TRANSACTION a set CUSTOMER_ID= ( select CUSTOMER.CUSTOMER_ID
from CUSTOMER b where a.CUSTOMER_NAME=b.NAME)
where exists (select 1 from CUSTOMER c where a.CUSTOMER_NAME=c.NAME);
from CUSTOMER b where a.CUSTOMER_NAME=b.NAME)
where exists (select 1 from CUSTOMER c where a.CUSTOMER_NAME=c.NAME);
解决方案 »
- 关于为什么要用游标的一个例子的问题
- sql数据排序的问题
- 关于ORACLE返回数据集的问题,望高手解答
- ORA-06550: 第 1 行, 第 7 列: PLS-00905: 对象 SYSTEM.GETA 无效 ORA-06550: 第 1 行, 第 7 列: PL/SQL: Statement ignored
- 关于oracle中dual的问题
- Oracle 11g 中to_date() 请教
- 请教如何用load data方法同时把相同的数据倒入2个表!
- oracle表删除、并恢复后出现程序运行出现的问题?
- 各位大虾,问一个oracle的sql问题,急,在线等待!
- ORACLE中有两列如何找出不同的
- oracle中提取一个date类型中的年份的函数是什么啊?
- Oracle的简单问题但很重要
where CUSTOMER.NAME=CUSTOMER_TRANSACTION.CUSTOMER_NAME)对每一个CUSTOMER.NAME,select出来的id必须只有一个值,否则会出错
最后一句:
where exists (select 1 from CUSTOMER c where a.CUSTOMER_NAME=c.NAME);
能起作用吗?
当c表中找不到 a.CUSTOMER_NAME,那怎么update?
case when exists (select 1 from CUSTOMER c where a.CUSTOMER_NAME=c.NAME)
then update CUSTOMER_TRANSACTION a set CUSTOMER_ID= ( select CUSTOMER.CUSTOMER_ID from CUSTOMER b where a.CUSTOMER_NAME=b.NAME)
else
处理语句
end
注意:CUSTOMER_TRANSACTION.CUSTOMER_NAME=CUSTOMER.NAME必需唯一