使用连接PL/SQL和on/and条件进行更新-它尝试更新所有行

使用连接PL/SQL和on/and条件进行更新-它尝试更新所有行,sql,join,sql-update,Sql,Join,Sql Update,我看过其他答案,看不出这个问题;我想更新一个字段,其中使用内部代码编号来确保两个客户是相同的,并且是特定订单上的客户 当我运行下面的代码时,我得到警告“你确定要更新所有记录吗”-不,我不 如何让it部门更新该客户记录,并且只更新该客户记录 谢谢大家! 您正在重复更新中的表名。您希望将其表述为: update CustomerTable ct set Text = 'text' from OrderTable ot where ot.Customer = ct.Customer and

我看过其他答案,看不出这个问题;我想更新一个字段,其中使用内部代码编号来确保两个客户是相同的,并且是特定订单上的客户

当我运行下面的代码时,我得到警告“你确定要更新所有记录吗”-不,我不



如何让it部门更新该客户记录,并且只更新该客户记录


谢谢大家!

您正在重复
更新中的表名。您希望将其表述为:

update CustomerTable ct
    set Text = 'text'
from OrderTable ot
where ot.Customer = ct.Customer and ot.Order = '10';
或者,在几乎可以在任何数据库中工作的结构中:

update CustomerTable ct
    set Text = 'text'
where exists (select 1
              from OrderTable ot
              where ot.Customer = ct.Customer and
                    ot.Order = '10'
             );

您正在重复更新中的表名。您希望将其表述为:

update CustomerTable ct
    set Text = 'text'
from OrderTable ot
where ot.Customer = ct.Customer and ot.Order = '10';
或者,在几乎可以在任何数据库中工作的结构中:

update CustomerTable ct
    set Text = 'text'
where exists (select 1
              from OrderTable ot
              where ot.Customer = ct.Customer and
                    ot.Order = '10'
             );

您使用的是什么dbms?您在标题中提到了PL/SQL,这是Oracle用于编写存储过程的语言(您的问题只包含普通SQL,但没有PL/SQL)。但是您不能使用Oracle,因为该语句对Oracle无效,并且会导致错误消息。您使用的是什么dbms?您在标题中提到了PL/SQL,这是Oracle用于编写存储过程的语言(您的问题只包含纯SQL,但没有PL/SQL)。但您不能使用Oracle,因为该语句对Oracle无效,并将导致错误消息。