zoukankan      html  css  js  c++  java
  • [K/3Cloud] KSQL 关联表更新字段Update语法

    关联表更新字段

    UPDATE tmp369faa3f7d224b0595670425008 as t1 SET FStatus=-1  
    where exists(select 1 from t_BD_Supplier where FUseOrgId = t1.FDestOrgID and FMasterId = t1.FMasterId)

    UPDATE 后面使用别名必须加AS;

    另一种写法:

    update t_pm_otherowner set fcontrolunitid=(select fcontrolunitid from t_pm_specialdataperm where fid=fspecialdatapermid);


    复杂更新语句:

    UPDATE T_SD_SaleContractEntry
    SET (FTotalOrderedAmt, FTotalOrderedQty) = 
    (SELECT temp.FTotalOrderedAmt, temp.FTotalOrderedQty  FROM TABLE temp 
    WHERE EXISTS(SELECT 1 FROM IDTABLE idtemp WHERE idtemp.FEntryID=temp.FSourceBillEntryId AND idtemp.FDstID IN (?)) AND T_SD_SaleContractEntry.FID=temp.FSourceBillEntryId)


    更新多条记录:
    Update 后不要使用别名更新。

    UPDATE T0 SET (FYEAR) = 
    (SELECT TO_INT(T1.FVALUE) FROM tmp0dd8fdf5aa1e4ebdad2a04d9266 T0 INNER JOIN T_BAS_SYSTEMPROFILE T1 ON T0.FBOOKID = T1.FACCOUNTBOOKID   WHERE T1.FCategory = 'GL' AND T1.FORGID = 0 AND T1.FKey = 'CurrentYear')

    在Oracle下提示T0不存在,应写为:

    UPDATE tmp55ff93c1200244a8848291ed180 SET (FYEAR) = ( SELECT T1.FVALUE FROM T_BAS_SYSTEMPROFILE T1 WHERE T1.FCategory = 'GL' AND T1.FORGID = 0 AND T1.FKey = 'CurrentYear' AND tmp55ff93c1200244a8848291ed180.FBOOKID = T1.FACCOUNTBOOKID)


  • 相关阅读:
    查询中常用的扩展方法
    加载关联表的数据 显式加载
    加载关联表的数据 延迟加载
    加载关联表的数据 贪婪加载
    操作内存中的数据
    DBContext基础查询
    EF简单增删改查
    1- MySQL数据库基础快速入门
    1-3 Postman 注册账号与登录
    1-2 postman工具简介
  • 原文地址:https://www.cnblogs.com/fyq891014/p/3308529.html
Copyright © 2011-2022 走看看