【问题标题】:Check and save data to update检查并保存数​​据以进行更新
【发布时间】:2022-09-27 17:41:28
【问题描述】:

我有一个问题,我需要在检查的同时保存查询的值以执行更新。怎么可能做到这一点?谁来帮帮我?

update table_one tone
set    tone.name = (name)
where  (select tthree.name as name
        from   table_two ttwo
        where  ttwo.name=\'sfsdf\'
        union
        select tthree.name as name
        from   table_three tthree
        where  tthree.name=\'sfsdf\') is not null;

    标签: oracle plsql


    【解决方案1】:

    我不确定您说要“保存”查询的值(保存方式?在哪里?)同时“检查”(如何?在哪里?)是什么意思。没错,您发布了一些代码,表明 tone.name 应该获得 (name) 的值,但是 - (name) 到底是什么?

    无论如何,这就是我思考您可能需要 - 看看并尝试一下。

    update table_one t1 set
      t1.name = (select max(x.name)
                 from (select t2.name from table_two t2 where t2.name = 'sfsdf'
                       union
                       select t3.name from table_three t3 where t3.name = 'sfsdf'
                      ) x
                )
      where exists (select null 
                    from (select t2.name from table_two t2 where t2.name = 'sfsdf'
                          union
                          select t3.name from table_three t3 where t3.name = 'sfsdf'
                         )
                   );
    

    如果那不是“它”,请编辑问题并发布一些示例数据来说明问题并解释您期望的结果以及原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多