数据库有三个表,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谢谢
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谢谢
SET CostPrice=CostPrice_View.CostPrice,
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
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你最好查查是否有结果?
RdRecords
SET
CostPrice=CostPrice_View.CostPrice,
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
一般么啥区别。 你去掉条件 后一步步查询
看到底是哪个条件的影响要学会自己DEBUG啊
最后update
成功了,在update !
CostPrice=CostPrice_View.CostPrice,
CostMoney=RdRecords.iQuantity*CostPrice_View.CostPrice
FROM
RdRecords,RdRecord,CostPrice_View
WHERE
RdRecord.[ID]=RdRecords.[ID]
AND
CostPrice_View.cInvCode=RdRecords.cInvCode
AND
RdRecord.cVouchType in ('413','414')
AND
RdRecord.iDate between CostPrice_View.BeginDate and CostPrice_View.EndDate
AND
RdRecord.cWhCode=CostPrice_View.cWhCode
AND CostPrice_View.iCode=1