oracle update left join 寫法

oracle update left join 寫法 (修改某列,條件字段在關聯表中)
案例:
E:考覈表 X,:用戶表
USERNAME 關聯
需求:修改營業部最高分
分析:經過登陸帳號的營業部ORG_ID 更新E表,E表中無ORG_ID 字段,X表中能夠關聯.
寫法一:
UPDATE USER_INFO E
SET E.TOP_SCORE =
(SELECT 230
FROM USER X
WHERE E.USERNAME = X.USERNAME
and X.ORG_ID = ‘B26603C4BB9B0042E0430ABC694C0042’)
WHERE E.USERNAME = (SELECT X.USERNAME
FROM USER X
WHERE E.USERNAME = X.USERNAME
and X.ORG_ID = ‘B26603C4BB9B0042E0430ABC694C0042’)oracle

寫法二:
UPDATE USER_INFO E
SET E.TOP_SCORE = 230
WHERE exists (SELECT X.USERNAME
FROM USER X
WHERE E.USERNAME= X.USERNAME
and X.ORG_ID = ‘B26603C4BB9B0042E0430ABC694C0042’)ide

寫法三:
UPDATE USER_INFO E
E.TOP_SCORE = 230
WHERE E.USERNAME in(
SELECT X.USERNAME FROM USER X WHERE
E.USERNAME =X.USERNAME and
X.ORG_ID=’B26603C4BB9B0042E0430ABC694C0042’)
---------------------
做者:guidestarzh
來源:CSDN
原文:https://blog.csdn.net/guidestarzh/article/details/81509058
版權聲明:本文爲博主原創文章,轉載請附上博文連接!ui

相關文章
相關標籤/搜索