update 多个表的问题

yumanqing yumanqing 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
数据库有三个表,RdRecord,RdRecords,CostPrice_View,
RdRecord 和 RdRecords是主从表,用 CostPrice_View 表中的字段更新RdRecords表中的字段,但是还有条件判断
查询语句如下,可是明明条件满足,显示更新数据0条,为什么?

UPDATE RdRecords
SET RdRecords.CostPrice=CostPrice_View.CostPrice,
RdRecords.CostMoney=RdRecords.iQuantity*CostPrice_View.CostPrice
FROM RdRecord,RdRecords,CostPrice_View
WHERE RdRecord.[ID]=RdRecords.[ID]
AND CostPrice_View.cInvCode=RdRecords.cInvCode
AND (RdRecord.cVouchType='413' or RdRecord.cVouchType='414')
AND RdRecord.iDate>=CostPrice_View.BeginDate
AND RdRecord.iDate<=CostPrice_View.EndDate
AND RdRecord.cWhCode=CostPrice_View.cWhCode
AND CostPrice_View.iCode=1

谢谢
...全文

相关推荐

ORACLE多表关联的update语句

在某个业务受理子系统BSS中, --客户资料表 create table customers ( customer_id number(8) not null, -- 客户标示 city_name varchar2(10) not null, -- 所在城市 customer_type char(2) not null, -- 客户类型 ... ) create unique index PK_customers on customers (customer_id) 由于某些原因,客户所在城市这个信息并不什么准确,但是在 客户服务部的CRM子系统中,通过主动服务获取了部分客户20%的所在 城市等准确信息,于是你将该部分信息提取至一张临时表中: create table tmp_cust_city ( customer_id number(8) not null, citye_name varchar2(10) not null, customer_type char(2) not null )

toice

ORACLE_多表关联_UPDATE_语句

把其它表作为条件和更新值的更新语句;例如: 两表(多表)关联update -- 仅在where字句中的连接 --这次提取的数据都是VIP,且包括新增的,所以顺便更新客户类别 update customers a -- 使用别名 set customer_type='01' --01 为vip,00为普通 where exists (select 1 from tmp_cust_city b where b.customer_id=a.customer_id )

arvin0825

MySQL中Update、select联用操作单表、多表,及视图与临时表的区别

本篇文章给大家分享了MySQL中Update、select联用操作单表、多表,及视图与临时表的区别,有兴趣的朋友学习下吧。

weixin_38593823

SQL Update多表联合更新的方法

主要介绍了SQL Update多表联合更新的方法,需要的朋友可以参考下

weixin_38644097

SQL update 多表关联更新的实现代码

主要介绍了SQL update 多表关联更新的实现代码,需要的朋友可以参考下

付出余切
评论 12
收藏 已收藏
分享
返回顶部
yumanqing
MS-SQL Server 34,876 成员 254,635 内容