①
update 表a set (a.字段1,a. = (select b.字段1 from 表b where a.字段2=b.字段2) where exists(select 1 from 表b where a.字段2=b.字段2)。
②
MERGE INTO TABLE1 A USING
(SELECT CODE,NAME
FROM TABLE2) B
ON (A.CODE= B.CODE)
WHEN MATCHED THEN
UPDATE SET UPDATE_DT = SYSDATE
WHEN NOT MATCHED THEN
INSERT
(CODE,
NAME)
VALUES (
‘001’,
B.NAME
)
③将没有关系的表的数据放到一行中输出
SELECT A.CODE,B.COL3,C.COL1
FROM
(SELECT * FROM TABLE1 ) A,
(SELECT * FROM TABLE2 ) B,
(SELECT * from
(SELECT t.* ,row_number()over(partition by CODE order by COL1 desc)rn FROM TABLE3 t WHERE COL6 = 1)
WHERE rn=1 ) C,
WHERE
A.CODE = B.CODE(+) AND
A.EMP_CODE = C.EMP_CODE(+)
④
UPDATE A
SET DATE=sysdate
WHERE LINK_TAISHOGAI_FG = ‘0’
AND (A.ID1,A.ID2,A.ID3) NOT IN
(SELECT B.ID1,B.ID2,B.ID3
FROM B
WHERE A.ID1= B.ID1
AND A.ID2 = B.ID2
AND A.ID3 = B.ID3
AND B.ID4 IN (‘A’,’B’,’C’
)
今天的文章UPDATE 用法总结分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/7334.html