Sql server 2005 在SQLServer2005Express中使用join
我有一个表,需要根据另一个表的信息进行更新。我编写了一个select查询,它工作得很好,并且准确地显示了我需要删除的内容,但是当我尝试将其更改为更新查询时,我在连接时会出错。我希望有人能向我指出这是一个简单的疏忽 以下是有效的select查询:Sql server 2005 在SQLServer2005Express中使用join,sql-server-2005,sql-server-express,Sql Server 2005,Sql Server Express,我有一个表,需要根据另一个表的信息进行更新。我编写了一个select查询,它工作得很好,并且准确地显示了我需要删除的内容,但是当我尝试将其更改为更新查询时,我在连接时会出错。我希望有人能向我指出这是一个简单的疏忽 以下是有效的select查询: select * from CustPayShdul JOIN ARcreditapply ON ARcreditapply.AplyedRefNo = CustPayShdul.ReferNo AND ARcreditapply.AplyedLoc
select *
from CustPayShdul
JOIN ARcreditapply
ON ARcreditapply.AplyedRefNo = CustPayShdul.ReferNo AND ARcreditapply.AplyedLocation = CustPayShdul.LocationNo
AND ARcreditapply.sequence2 = CustPayShdul.Paysequence
where ARcreditapply.PaidDate < '1/1/2012' and ARcreditapply.PaidDate < CustPayShdul.InvDate
选择*
从卡斯帕伊什杜尔
加入Arcreditaply
在arcreditaply.AplyedRefNo=CustPayShdul.refereno和arcreditaply.AplyedLocation=CustPayShdul.LocationNo上
arcreditaply.sequence2=CustPayShdul.Paysequence
其中arcreditaply.PaidDate<'1/1/2012'和arcreditaply.PaidDate
以下是返回错误的更新查询:
update custpayshdul
set custpayshdul.payablebalance = custpayshdul.amount
JOIN ARcreditapply
ON ARcreditapply.AplyedRefNo = CustPayShdul.ReferNo AND ARcreditapply.AplyedLocation = CustPayShdul.LocationNo
AND ARcreditapply.sequence2 = CustPayShdul.Paysequence
where ARcreditapply.PaidDate < '1/1/2012' and ARcreditapply.PaidDate < CustPayShdul.InvDate
更新custpayshdul
设置custpayshdul.payableball=custpayshdul.amount
加入Arcreditaply
在arcreditaply.AplyedRefNo=CustPayShdul.refereno和arcreditaply.AplyedLocation=CustPayShdul.LocationNo上
arcreditaply.sequence2=CustPayShdul.Paysequence
其中arcreditaply.PaidDate<'1/1/2012'和arcreditaply.PaidDate
您在加入之前错过了custpayshdul的。尝试:
update custpayshdul
set payablebalance = custpayshdul.amount
FROM custpayshdul
JOIN ARcreditapply
ON ARcreditapply.AplyedRefNo = CustPayShdul.ReferNo AND ARcreditapply.AplyedLocation = CustPayShdul.LocationNo
AND ARcreditapply.sequence2 = CustPayShdul.Paysequence
where ARcreditapply.PaidDate < '1/1/2012' and ARcreditapply.PaidDate < CustPayShdul.InvDate
更新custpayshdul
设置应付款余额=custpayshdul.amount
从卡斯帕伊什杜尔
加入Arcreditaply
在arcreditaply.AplyedRefNo=CustPayShdul.refereno和arcreditaply.AplyedLocation=CustPayShdul.LocationNo上
arcreditaply.sequence2=CustPayShdul.Paysequence
其中arcreditaply.PaidDate<'1/1/2012'和arcreditaply.PaidDate
这些错误是什么??请给我们准确完整的错误信息…你太棒了!!!!!!!!工作得很有魅力!这让我快发疯了!非常感谢你!很乐意帮忙!如果你也能把它作为答案,那就太棒了;)