检查并保存要更新的数据

3yhwsihp  于 2022-10-04  发布在  Oracle
关注(0)|答案(1)|浏览(126)

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

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;
yqkkidmi

yqkkidmi1#

我不确定您说要“保存”查询的值是什么意思(保存方式?在哪里?)在你“检查”的同时(如何?在哪里?)。是的,您发布了一些代码,建议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'
                     )
               );

如果不是这样,请编辑问题并发布一些示例数据来说明问题,并解释您预期的结果和原因。

相关问题