两个表A,B通过字段ID INNER JOIN连接,现想更新表B中的QTY值为表A的QTY值,但只更新这两个QTY不一样的部分,一样的不动。
解决方案 »
- 在线急等:请教几条简单的查询SQL语句
- oracle imp 错误942
- 数据链的表关联问题。。。。。
- 如何返回存储过程中的值!我是一个新手 请大家帮一下帮 谢谢!!!!!!
- OEM中,为什么作业总是失败啊!提示说首先项证明无效或没权限,整整以下午也没弄明白,帮忙啦!
- oracle里如何判断某个表已经存在?
- 在REDHAT LINUX下如何进入OEM管理界面?(分数立给)
- 初学orcle,不知道从那里入手
- ===大型ERP系统,如SAP,在报表开发中,是否需要学习PLSQL程序设计?===
- 我在oracle数据库删除表和导入dmp文件时报了很多错,能帮我看看嘛
- 多表事务问题
- 请教一个查询的语句,不太会Oracle
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
using (select b.* from a, b where a.id = b.id and a.qty <> b.qty ) b
on (a.id = b.id)
when matched then
update set a.qty = b.qty
when not matched then
insert (a.id,a.qty)
values(b.id,b.qty)
merge into B
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where B.QTY<>A.QTY;
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where B.QTY<>A.QTY;