I have a table in which I need to update based on the info from another. I wrote a select query that works great and shows exactly what I need to get rid of, but when when I try to change it to an update query, I get errors on Join. I hope it is a simple oversight that someone can point out to me.
Here is the select query that works:
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
Here is the update query that returns an error:
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
You’re missing the
FROM custpayshdulbefore your join. Try: