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);
解决方案 »
- 关于oracle精简版实例问题
- 请教个sql
- Oracle10g 安装失败 (严重: 参数 PORT 的值 null 无效)
- 修改特别慢
- 查询出生日期为最近一个星期的sql还真不好写!日期是从今天向后推算.在线苦等......
- 有没有什么查询语句可以得到Oracle的版本号?
- 了解一下北京程序员的薪水~!希望大家实话实说,最好都说的详细点!!
- 各位大侠,我在建索引时报错:“ORA-00054: 资源正忙,要求指定 NOWAIT”,不知应如何解决?
- 存储过程的参数传递
- vmware esxi虚拟主机部署ORACLE 11G RAC--咨询帖
- 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必需唯一