update customerbak1 set owner=(select handleby_id
from tx where tx.customer_guid=customerbak1.customer_guid )
这个sql更新 受影响行数有365503行而卧用
select count(*) from customerbak1 where customer_guid in(select customer_guid from tx)
查出记录数为5586,而 select count(*) from customerbak1 出来的记录正好是365503行 ,请问为何我这条update有问题?
正常应该更新的记录数应该是5586行啊?
求高手解答
from tx where tx.customer_guid=customerbak1.customer_guid )
where customer_guid in(select customer_guid from tx)
可以把in改成exists试一下。或者
UPDATE customerbak1 aa
SET owner =
(SELECT handleby_id
FROM tx
WHERE tx.customer_guid = aa.customer_guid
AND EXISTS
(SELECT 1 FROM TX WHERE tx.customer_guid = aa.customer_guid));
from tx where tx.customer_guid=customerbak1.customer_guid )
少了where 条件.
update customerbak1 set owner=(select handleby_id
from tx where tx.customer_guid=customerbak1.customer_guid ) where x